This is Part 4 of our Equivalence Partitioning series.
In previous articles we looked at identifying partitions for a single input. Here we extend the technique to multiple inputs and show how each-choice coverage can dramatically reduce the number of tests while still achieving 100% Equivalence Partitioning coverage.
- To achieve 100% equivalence partitioning in testing, we must run a test for each partition.
- Some output behaviours depend on just 1 input – such as the ability to buy cigarettes – e.g. someone born after 2009 cannot legally be sold cigarettes, the input here is just age.
- Others require multiple inputs – if you are under 18 you cannot buy alcohol, but if you are 16-17 you can drink alcohol with a meal if accompanied by an adult, but you cannot buy it yourself.
- For multiple inputs we are not interested in testing all the combinations, just the partitions, as before. Here we call it ‘each choice’ coverage – each partition from each set of partitions is exercised at least once.
Example illustrating multiple inputs:
Input Partitions:
- Age under 16
- Age 16-17
- Age 18 or over
- Accompanied by an adult
- Unaccompanied
Output Partitions
6. Cannot buy alcohol
7. Can buy alcohol
8. Can have alcohol with a meal
We have 8 partitions, but only 3 tests are required for each 'each choice' coverage,
TC1 – Age 15, unaccompanied: Cannot buy alcohol (EP 1, 5, and 6)
TC2 – Age 17, accompanied: Cannot buy alcohol but can have it with a meal (EP 2, 4, 6, and 8)
TC3 – Age 20: Can buy alcohol (EP 3 and 7).
For combination coverage we would have to add test cases to cover, for instance, an unaccompanied 17-year-old. Very likely in the real world, but not necessary to be covered in the simplistic ‘each-choice’ coverage measure.