Selecting test cases is the single most important task that software testers do and equivalence partitioning, sometimes called equivalence classing, is the means by which they do it. Equivalence partitioning is the process of methodically reducing the huge (infinite) set of possible test cases into a much smaller, but still equally effective, set. Remember the Windows Calculator example from Chapter 3? It's impossible to test all the cases of adding two numbers together. Equivalence partitioning provides a systematic means for selecting the values that matter and ignoring the ones that don't. For example, without knowing anything more about equivalence partitioning, would you think that if you tested 1+1, 1+2, 1+3, and 1+4 that you'd need to test 1+5 and 1+6? Do you think you could safely assume that they'd work? How about 1+99999999999999999999999999999999 (the maximum number you can type in)? Is this test case maybe a little different than the others, maybe in a different class, a different equivalence partition? If you had the choice, would you include it or 1+13? See, you're already starting to think like a software tester! NOTE An equivalence class or equivalence partition is a set of test cases that tests the same thing or reveals the same bug. What is the difference between 1+99999999999999999999999999999999 and 1+13? In the case of 1+13, it looks like a standard simple addition, a lot like 1+5 or 1+392. However, 1+999... is way out there, on the edge. If you enter the largest possible number and then add 1 to it, something bad might happenpossibly a bug. This extreme case is in a unique partition, a different one from the normal partition of regular numbers. NOTE When looking for equivalence partitions, think about ways to group similar inputs, similar outputs, and similar operation of the software. These groups are your equivalence partitions. Look at a few examples:
Remember, the goal of equivalence partitioning is to reduce the set of possible test cases into a smaller, manageable set that still adequately tests the software. You're taking on risk because you're choosing not to test everything, so you need to be careful how you choose your classes. NOTE If you equivalence partition too far in your effort to reduce the number of test cases, you risk eliminating tests that could reveal bugs. If you're new to testing, always get someone with more experience to review your proposed classes. A final point about equivalence partitioning is that it can be subjective. It's science but it's also art. Two testers who test a complex program may arrive at two different sets of partitions. That's okay as long as the partitions are reviewed and everyone agrees that they acceptably cover the software being tested. |