Equivalence Partitioning


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:

  • In the case of adding two numbers together, there seemed to be a distinct difference between testing 1+13 and 1+99999999999999999999999999999999. Call it a gut feeling, but one seemed to be normal addition and the other seemed to be risky. That gut feeling is right. A program would have to handle the addition of 1 to a maxed-out number differently than the addition of two small numbers. It would need to handle an overflow condition. These two cases, because the software most likely operates on them differently, are in different equivalence partitions.

    If you have some programming experience, you might be thinking of several more "special" numbers that could cause the software to operate differently. If you're not a programmer, don't worryyou'll learn the techniques very shortly and be able to apply them without having to understand the code in detail.

  • Figure 5.3 shows the Calculator's Edit menu selected to display the copy and paste commands. There are five ways to perform each function. For copy, you click the Copy menu item, type c or C when the menu is displayed, or press Ctrl+c or Ctrl+Shift+c. Each input path copies the current number into the Clipboardthey perform the same output and produce the same result.

    Figure 5.3. The multiple ways to invoke the copy function all have the same result.


    If your job is to test the copy command, you could partition these five input paths down to three: Clicking the command on the menu, typing a c, or pressing Ctrl+c. As you grow more confident with the software's quality and know that the copy function, no matter how it's enabled, is working properly, you might even partition these down into a single partition, maybe Ctrl+c.

  • As a third example, consider the possibilities for entering a filename in the standard Save As dialog box (see Figure 5.4).

    Figure 5.4. The File Name text box in the Save As dialog box illustrates several equivalence partition possibilities.


    A Windows filename can contain any characters except \/ : * ? " < > and |. Filenames can have from 1 to 255 characters. If you're creating test cases for filenames, you will have equivalence partitions for valid characters, invalid characters, valid length names, names that are too short, and names that are too long.

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.



    Software Testing
    Lessons Learned in Software Testing
    ISBN: 0471081124
    EAN: 2147483647
    Year: 2005
    Pages: 233

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net