4.2 Equivalence Partitioning
Key Takeaways
- Equivalence partitioning divides data into groups expected to behave the same way.
- Each partition should be tested at least once when that partition is in scope.
- Partitions may be valid or invalid.
- Partitions should be mutually exclusive and collectively cover the relevant input domain.
- EP reduces test volume while preserving meaningful behavioral coverage.
Core Idea
Equivalence partitioning, often shortened to EP, divides possible values into partitions that should be processed in the same way. If every value in a partition is expected to produce the same behavior, one representative value can provide useful coverage of that partition.
The technique works because exhaustive testing is impossible for most systems. A field that accepts ages from 18 through 65 has 48 valid integer values. Testing all 48 may add little value if the system treats them identically. EP lets you test one representative valid age plus representative invalid ages.
Partitions can be valid or invalid. A valid partition contains values the system should accept. An invalid partition contains values the system should reject or handle safely.
A good partition set is mutually exclusive, meaning each value belongs to one partition only. It is also complete for the test basis, meaning every relevant value is covered by some partition.
Worked Example: Age Eligibility
Requirement: A user can register for a professional exam if their age is from 18 through 65 inclusive. Age must be a whole number.
Relevant partitions:
| Partition | Type | Example value | Expected behavior |
|---|---|---|---|
| Less than 18 | Invalid | 16 | Reject as too young |
| 18 through 65 | Valid | 40 | Accept age |
| Greater than 65 | Invalid | 70 | Reject as too old |
| Not a whole number | Invalid | 20.5 | Reject format |
| Not numeric | Invalid | abc | Reject format |
A minimal EP set could be 16, 40, 70, 20.5, and abc. That covers each partition once. It does not yet focus on boundary values such as 17, 18, 65, and 66. Boundary value analysis is usually added after EP when range edges matter.
Worked Example: Shipping Method
Requirement: Shipping method must be Standard, Express, or Overnight. Digital products require No Shipping. Other values are invalid.
Partitions are category based rather than numeric:
| Partition | Type | Representative test |
|---|---|---|
| Standard shipping | Valid | Physical book plus Standard |
| Express shipping | Valid | Physical book plus Express |
| Overnight shipping | Valid | Physical book plus Overnight |
| No Shipping for digital product | Valid | E-book plus No Shipping |
| Unsupported method | Invalid | Physical book plus Drone |
| Missing method | Invalid | Physical book plus blank method |
This example shows that EP is not only for numbers. It works for roles, file types, payment methods, countries, plan tiers, status codes, and input formats.
Common Exam Traps
Do not choose several values from the same partition and claim higher EP coverage. If 21, 35, and 50 are all in the same valid age partition, they still cover one partition. More values may be useful for other reasons, but not for additional EP coverage.
Do not combine invalid partitions into one vague invalid bucket when different failure handling is expected. A negative age, decimal age, and alphabetic age may be rejected by different validation paths. If the expected behavior or processing differs, they are separate partitions.
Do not forget output partitions. EP can apply to outputs as well as inputs. For example, a discount calculation may output no discount, small discount, loyalty discount, or maximum discount.
Coverage Measurement
EP coverage is measured as the number of partitions exercised by at least one test divided by the total identified partitions.
If a feature has 6 partitions and tests cover 5 of them, EP coverage is 5 / 6 = 83.3 percent. The uncovered partition should be visible in test reporting so stakeholders understand the remaining gap.
Practical Design Flow
First, identify the variable or condition being tested. Second, list values that should be treated the same. Third, separate valid and invalid behavior. Fourth, select one representative value per partition. Fifth, add boundary values if a numeric or ordered range has edges.
EP is efficient, but it depends on the quality of the partitioning. If the tester misunderstands the requirement, the partitions will be wrong even if the coverage calculation looks precise.
A password must contain 8 through 64 characters. Which value is a representative member of the valid equivalence partition?
For a required ZIP code field that accepts exactly five digits, which are reasonable invalid equivalence partitions?
Select all that apply