Boundary Value Analysis 2
Boundary Value Analysis 2
5.5 Examples
Each of the three continuing examples is a function of three variables. Printing all the test cases
from all the methods for each problem is very space consuming, so we just have selected examples
for worst-case boundary value and robust worst-case boundary value testing.
1 1 1 1 Equilateral
2 1 1 2 Not a triangle
6 1 2 1 Not a triangle
7 1 2 2 Isosceles
1 1 1 1812 1, 2, 1812
2 1 1 1813 1, 2, 1813
3 1 1 1912 1, 2, 1912
4 1 1 2011 1, 2, 2011
5 1 1 2012 1, 2, 2012
6 1 2 1812 1, 3, 1812
7 1 2 1813 1, 3, 1813
8 1 2 1912 1, 3, 1912
9 1 2 2011 1, 3, 2011
10 1 2 2012 1, 3, 2012
21 1 31 1812 2, 1, 1812
22 1 31 1813 2, 1, 1813
23 1 31 1912 2, 1, 1912
24 1 31 2011 2, 1, 2011
25 1 31 2012 2, 1, 2012
26 2 1 1812 2, 2, 1812
27 2 1 1813 2, 2, 1813
28 2 1 1912 2, 2, 1912
(continued)
29 2 1 2011 2, 2, 2011
30 2 1 2012 2, 2, 2012
31 2 2 1812 2, 3, 1812
32 2 2 1813 2, 3, 1813
33 2 2 1912 2, 3, 1912
34 2 2 2011 2, 3, 2011
35 2 2 2012 2, 3, 2012
51 6 1 1812 6, 2, 1812
52 6 1 1813 6, 2, 1813
53 6 1 1912 6, 2, 1912
54 6 1 2011 6, 2, 2011
55 6 1 2012 6, 2, 2012
56 6 2 1812 6, 3, 1812
57 6 2 1813 6, 3, 1813
(continued)
58 6 2 1912 6, 3, 1912
59 6 2 2011 6, 3, 2011
60 6 2 2012 6, 3, 2012
66 6 30 1812 7, 1, 1812
67 6 30 1813 7, 1, 1813
68 6 30 1912 7, 1, 1912
69 6 30 2011 7, 1, 2011
70 6 30 2012 7, 1, 2012
Barrels
90
72
40
22.2 40 70
Locks
33.3
60
80
Stocks
5 5 5 5 500 50 Midpoint
The volume between the origin and the lower plane corresponds to sales below the $1000
threshold. The volume between the two planes is the 15% commission range. Part of the reason
for using the output range to determine test cases is that cases from the input range are almost all
in the 20% zone. We want to find input variable combinations that stress the sales/commission
boundary values: $100, $1000, $1800, and $7800. The minimum and maximum were easy, and
the numbers happen to work out so that the border points are easy to generate. Here is where it
gets interesting: test case 9 is the $1000 border point. If we tweak the input variables, we get values
just below and just above the border (cases 6–8 and 10–12). If we wanted to, we could pick values
near the borders such as (22, 1, 1). As we continue in this way, we have a sense that we are “exercis-
ing” interesting parts of the code. We might claim that this is really a form of special value testing
because we used our mathematical insight to generate test cases.
Table 5.4 contains test cases derived from boundary values on the output side of the commis-
sion function. Table 5.5 contains special value test cases.
5.6 Random Testing
At least two decades of discussion of random testing are included in the literature. Most of this
interest is among academics, and in a statistical sense, it is interesting. Our three sample problems
lend themselves nicely to random testing. The basic idea is that, rather than always choose the min,
min+, nom, max–, and max values of a bounded variable, use a random number generator to pick
test case values. This avoids any form of bias in testing. It also raises a serious question: how many
random test cases are sufficient? Later, when we discuss structural test coverage metrics, we will
have an elegant answer. For now, Tables 5.6 through 5.8 show the results of randomly generated
test cases. They are derived from a Visual Basic application that picks values for a bounded variable
a ≤ x ≤ b as follows:
91 1 6 84
27 1 1 25
72 1 1 70
176 1 6 169
48 1 1 46
152 1 6 145
125 1 4 120
x = Int((b – a + 1) * Rnd + a)
where the function Int returns the integer part of a floating point number, and the function Rnd
generates random numbers in the interval [0, 1]. The program keeps generating random test cases
until at least one of each output occurs. In each table, the program went through seven “cycles”
that ended with the “hard-to-generate” test case. In Tables 5.6 and 5.7, the last line shows what
percentage of the random test cases was generated for each column. In the table for NextDate, the
percentages are very close to the computed probability given in the last line of Table 5.8.
Feb. 28 of a
Days 1–27 Feb. 28 of a Non-Leap Feb. 29 of a Impossible
of Feb. Leap Year Year Leap Year Days
45 1 1 1 22
83 1 1 1 19
312 1 8 3 77
92 1 4 1 19
417 1 11 2 94
310 1 6 5 75
126 1 5 1 26
When we add the semantic information that F calculates the miles per gallon of an automo-
bile, where a and b are end and start trip odometer values, and c is the gas tank capacity, we see
more severe problems:
1. We must always have a ≥ b. This will avoid the negative values of F (test cases 1, 2, 9, and 10).
2. Test cases 3, 8, and 12–15 all refer to trips of length 0, so they could be collapsed into one
test case, probably test case 8.
3. Division by zero is an obvious problem, thereby eliminating test case 11. Applying the
semantic knowledge will result in the better set of case cases in Table 5.10.
4. Table 5.10 is still problematic—we never see the effect of boundary values on the tank capacity.
EXERCISES
1. Develop a formula for the number of robustness test cases for a function of n variables.
2. Develop a formula for the number of robust worst-case test cases for a function of n variables.
3. Make a Venn diagram showing the relationships among test cases from boundary value
analysis, robustness testing, worst-case testing, and robust worst-case testing.
4. What happens if we try to do output range robustness testing? Use the commission problem
as an example.
5. If you did exercise 8 in Chapter 2, you are already familiar with the CRC Press website for
downloads (http://www.crcpress.com/product/isbn/9781466560680). There you will find
an Excel spreadsheet named specBasedTesting.xls. (It is an extended version of Naive.xls,
and it contains the same inserted faults.) Different sheets contain worst-case boundary value
test cases for the triangle, NextDate, and commission problems, respectively. Run these sets
of test cases and compare the results with your naive testing from Chapter 2.
6. Apply special value testing to the miles per gallon example in Tables 5.9 and 5.10. Provide
reasons for your chosen test cases.