Learning Objectives
By the end of this lesson you will be able to:
- Define equivalence partitioning and explain its purpose
- Describe what makes a set of values an "equivalence class"
- Explain why testing one value per class is sufficient
The Core Idea
Imagine a field that accepts a person's year of birth. Any integer from 1900 to the current year is valid. There are tens of thousands of possible valid inputs.
Do you need to test all of them? No — and here's why.
If the system correctly handles birth year 1985, it will also correctly handle 1972, 1990, and 2001. They all belong to the same equivalence class: values that the system treats identically. Testing one representative from this class is enough because the underlying code path is the same for all of them.
This is Equivalence Partitioning: the technique of grouping inputs so that testing one value per group tells you how the system behaves for the entire group.
Formal Definition
An equivalence class (also called an equivalence partition) is a set of input values for which a system is expected to behave in the same way — executing the same code path and producing the same type of output.
The word "type" is important. The output doesn't need to be identical — a birth year of 1985 produces a different age than 1990 — but the behavior (accept, process, respond) should be consistent across the class.
How Partitioning Works in Practice
For any input, the process is:
- Identify the specification: What values are valid? What values are invalid? (e.g., "age must be between 0 and 120")
- Define the partitions:
- Valid partition: ages 0–120 (test representative: 35)
- Invalid partition below: negative numbers (test representative: -1)
- Invalid partition above: ages > 120 (test representative: 150)
- Select one representative per partition
Three test cases, not 122.
Why This Works (The Theory)
Software generally implements boundaries as conditional statements: if (age >= 0 && age <= 120). Once you know that the condition correctly passes age 35 and rejects age -1 and 150, you know the logic is correct for all values in those ranges — unless the developer made different mistakes for different specific values (extremely rare and a separate concern).
Pro Tip: Equivalence partitioning works best when combined with Boundary Value Analysis (covered in the next module). EP tells you which groups exist; BVA tells you where to test within the groups.
The Common Mistake
Testers new to EP often confuse "equivalence class" with "valid input range." Remember: invalid inputs also form equivalence classes. For a birth year field:
- Valid class: 1900–current year → pick one
- Invalid class (too old): anything < 1900 → pick one
- Invalid class (future): anything > current year → pick one
Testing only the valid class means you never verify that the system actually rejects invalid input.
Key Takeaways
- Equivalence partitioning divides the input space into groups that the system treats identically
- You need at least one valid partition and typically one or more invalid partitions
- Testing one representative per partition gives you coverage without redundant tests
- Both valid AND invalid partitions must be represented in your test suite