Key takeaways
- Equivalence partitioning splits possible inputs into groups (partitions) the software should handle the same way.
- If one value from a partition works, the others very likely do too. So you test one value per partition.
- Always include invalid partitions: wrong types, empty values, out-of-range numbers. Many bugs live there.
The problem: too many inputs
An exam app accepts a score from 0 to 100. A score of 50 or more passes.
You could test 0, 1, 2… all the way to 100. Then -1, -2, 101, 1,000, "abc", an empty field… The list never ends. You need a smarter way to choose.
The idea: group values that behave the same
Think about how the software should treat each value:
- Every score from 0 to 49 should give Fail.
- Every score from 50 to 100 should give Pass.
- Every score below 0 or above 100 should be rejected.
Each of those groups is an equivalence partition. If 30 gives "Fail", there's little reason to expect 31 or 32 to behave differently. They go through the same logic.
So instead of 100+ tests, you test one representative value from each partition.
Worked example
| Partition | Valid? | Example value | Expected result |
|---|---|---|---|
| Below 0 | Invalid | -5 | Error: "Score must be between 0 and 100" |
| 0 to 49 | Valid | 25 | Fail |
| 50 to 100 | Valid | 75 | Pass |
| Above 100 | Invalid | 150 | Error: "Score must be between 0 and 100" |
| Not a number | Invalid | abc | Error: "Enter a number" |
| Empty | Invalid | (nothing) | Error: "Score is required" |
| Decimal | Depends on the rules | 72.5 | Ask: are decimals allowed? |
Seven tests, and each one checks a different behaviour. That last row shows another benefit: partitioning makes you notice questions the requirement didn't answer.
Not just numbers
Partitions work for any input or condition the software treats differently:
- Payment methods: card, PayPal, bank transfer, voucher.
- User roles: guest, customer, admin.
- File types: PDF, JPG, PNG, and an unsupported type like EXE.
- Countries: ones you ship to, ones you don't.
An online shop tested its payment form with lots of Visa card numbers. All passed.
A tester applied equivalence partitioning to card types: Visa, Mastercard and American Express are three partitions, because the system validates them differently. One test per type.
The Amex test failed. American Express numbers have 15 digits, while Visa and Mastercard numbers usually have 16. The form required exactly 16 digits, so every Amex customer was rejected.
Lesson: fifty tests from the same partition gave the same answer fifty times. One test from a different partition found the bug.
How to do it, step by step
- Pick an input or condition, such as a field, a setting or a user type.
- Find the rules. What values are allowed? Which ones lead to different results?
- List the partitions, both valid and invalid.
- Pick one value from each. Prefer a value in the middle of the range.
- Write the expected result for each, from the requirement.
Its partner: boundary values
Equivalence partitioning picks a value from the middle of each group. But many bugs sit at the edges between groups: 49 and 50, 100 and 101.
That's why it's almost always used with boundary value analysis, which tests exactly those edges. See Boundary value analysis, and for a more advanced combined walkthrough, Equivalence partitioning and boundary values: beyond the basics.
Check yourself
A password must be 8 to 20 characters long. What are the equivalence partitions for its length?
Show answer
Three partitions: fewer than 8 characters (invalid, e.g. 4), 8 to 20 (valid, e.g. 12) and more than 20 (invalid, e.g. 30). You could add an empty password as a separate invalid case, since systems often handle it differently.
