Equivalence Class Testing

Profile picture for user devraj

Equivalence partitioning is a software testing technique that involves dividing input data into equivalent partitions, or classes, to generate test cases. This partition should be done in such a way that all the members of a given partition are expected to be processed in the same way. This technique, also known as equivalence class partitioning (ECP), is a form of black-box testing, as it does not require knowledge of the internal structure or implementation of the system.

Equivalence partitioning is a technique that can be applied at all levels of testing and is based on the requirements and specifications of the software being tested.

Table and Contents

  1. Valid and Invalid Partition
  2. Example of Equivalence Partitioning
  3. Test Coverage in Equivalence Partitioning
  4. Guidelines for Equivalence Partitioning
  5. Advantages of Equivalence Partitioning
  6. Disadvantages of Equivalence Partitioning
  7. Video Tutorial

Valid and Invalid Equivalence Partition

In equivalence partitioning, there should be separate partitions for both valid and invalid input values.

  • Valid Equivalence Partition: An equivalence partition containing valid values is known as a valid equivalence partition, where valid values are values accepted by the system or component.
  • Invalid Equivalence Partition: An equivalence partition containing invalid values is known as an invalid equivalence partition, where invalid values are values rejected by the system or component.

Example of Equivalence Partitioning

As an example, consider a scenario where a bank's credit card approval process requires applicants to be between the ages of 21 and 55. Using equivalence partitioning, we can identify the following classes, or partitions, of input data:

  • Invalid class: applicants who are less than 21 years old (age < 21)
  • Valid class: applicants who are between the ages of 21 and 55 (21 ≤ age ≤ 55)
  • Invalid class: applicants who are greater than 55 years old (age > 55)
InvalidValidInvalid
age < 2121 ≤ age ≤ 55age > 55
152560

Test Coverage in Equivalence Partitioning

In equivalence partitioning, test coverage is achieved by deriving at least one test case from each partition of input data. To achieve complete coverage, it is necessary to create test cases that cover all identified partitions, including both valid and invalid ones. This ensures that the system under test has been adequately tested with a representative set of input data.

Consider the Bank credit card example above. if we only test for valid input where the age is 25, then the coverage percentage would be 1/3 * 100 = 33.33%. This is because we are only testing one valid partition out of a total of three partitions (valid, invalid age <21 and invalid age >55).

It is important to note that using multiple values for a single partition does not increase the coverage percentage. In order to achieve 100% coverage, it is necessary to also test values for the remaining two invalid partitions.

Guidelines for Equivalence Partitioning

The International Software Testing Qualifications Board (ISTQB) provides the following guidelines for using equivalence partitioning in software testing:

  • Partitions can be identified for any data element related to the test object. This includes inputs, outputs, internal values, time-related values, and interface parameters.
  • Any partition may be divided into sub-partitions if needed.
  • Each value must belong to one and only one equivalence partition.
  • When testing invalid equivalence partitions, they should be tested individually or should not be combined with other invalid equivalence partitions to avoid failure masking. Failure masking occurs when several failures occur simultaneously, and only one is visible, causing the other failures to go undetected.

By following these guidelines, testers can effectively use equivalence partitioning to identify and test relevant input data and ensure the quality of the system under test.

Advantages of Equivalence Partitioning 

Equivalence partitioning has several advantages that make it a useful technique for software testing. 

  • One advantage is that it defines test cases that are specifically designed to uncover classes of errors. By dividing input data into equivalent partitions, testers can identify and address any issues that may arise when the system processes different types of data. 
  • Another advantage of equivalence partitioning is that it is a technique that can be used to efficiently reduce the number of test cases that need to be developed when testing a system with a large number of possible input combinations. This can save time and resources by reducing the total number of test cases that must be created and executed. 

Disadvantages of Equivalence Partitioning

Equivalence partitioning has several disadvantages that testers should be aware of when deciding whether or not to use this technique. 

  • One disadvantage is that it does not consider the conditions for boundary value analysis, which means that all necessary input combinations may not be covered. This can lead to incomplete testing and potentially missed defects. 
  • Another disadvantage is that a good understanding of the requirements is needed to design effective test cases using this technique. Testers who do not have a strong understanding of the requirements may struggle to create effective test cases using equivalence partitioning. 
  • Finally, this technique requires experience and expertise to be used effectively, especially when testing complex systems. Testers who are not familiar with equivalence partitioning or do not have the necessary experience may have difficulty designing effective test cases using this technique.