By: Vicky Davis
Conventional wisdom dictates that it is not possible to test all possible inputs when testing a software application. For instance, in the following pseudo code an infinite number of inputs can be used to test if “something” or “something else” happens. This Equivalence Partitioning technique helps reduce the number of total tests that determine if “something” or “something else” happens.
Dim a as Integer
If (a > 1) and (a < 5) Then
‘Do “something else”
First, let’s look at testing whether “something” occurs. If atakes the value 2, 3, and 4, then “something” is expected to happen. It is easy and quick to test three values to verify “something” occurs, however what if 5 is changed to 500? That is still easy to test but it is going to take longer.
To test if “something else” happens, there are an infinite number of values that acan take. By using Equivalence Partitioning, only three tests are needed. To test if “something” happens, the values, 2, 3, and 4, all produce the same result so only one needs to be tested. To test if “something else” happens, then all values greater than 5 and all value less than one will cause “something else” to happen. All that is needed then to test “something else” is two tests, one greater than 5 and one less than 1.
Boundary values also play a key role in testing by allowing the tester to make better choices regarding which values to choose for Equivalence Partitioning. For the pseudo code above, the boundary values are 0, 1, 2, 4, 5, and 6. For example, boundary values testing will reveal defects caused by incorrect indexing when using arrays and incorrect looping structures.
Equivalence Partitioning and Boundary Values are not enough to sufficiently test the code because you still have to consider Negative Tests (negative numbers, blank values, and invalid input). It is, however, ideal for unit testing and for reducing the number of tests needed to verify results.