Equivalence classes
One representative of a class, if behaviour is the same inside it.
An equivalence class is a set of values on which the product must behave the same way. For an "age 18 and over" field, the class "too young" covers 0 and 17 if there is one rule: rejection. You do not need to enter 1, then 2, then 3. You need one representative of the class, and the boundaries separately.
Classes are found by the rule, not by what is convenient to type. An empty value is often its own class, even if it is "also wrong": the message may differ from the "number too small" message. Letters in a numeric field are a third class. Negative numbers are a fourth if they are rejected for a different reason than a fraction.
It is a mistake to put into one class things that only look alike. A 0 percent discount and no discount may go through different code. If you are unsure that the code is the same, treat them as two classes until a developer or the requirement says otherwise. Doubt costs one extra check; a missed class costs a defect.
A case names both the class and a concrete representative. "An invalid age, for example 10." The reader understands that the point is not the number 10 but the class under 18. The next tester will not superstitiously repeat only the ten.
Practice
How many values from a class
There is one rule: an age under 18 is rejected the same way. What is enough to check inside the class?
- Every number from 0 to 17
- One representative of the class
- Only the lucky 25 and 40
- None, the class has already been named
An empty field
An empty value and the number 10 are both "invalid". Are they always one class? Answer yes or no.
Where to split classes
Select a sensible split for a numeric age.
- An empty field separately
- Letters instead of a number separately
- 1 and 2 as two required classes with the same rejection
- A valid age of 30 as the successful class