21.08.2013 Views

Software Engineering for Students A Programming Approach

Software Engineering for Students A Programming Approach

Software Engineering for Students A Programming Approach

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

second. So we devise two tests:<br />

Test number Data Outcome<br />

1 12 cannot vote<br />

2 21 can vote<br />

19.4 Black box (functional) testing 271<br />

We have reasoned that we need two sets of test data to test this program. These two<br />

sets, together with a statement of the expected outcomes from testing, constitute a test<br />

specification. We run the program with the two sets of data and note any discrepancies<br />

between predicted and actual outcome.<br />

Un<strong>for</strong>tunately we can see that these tests have not investigated the important distinction<br />

between someone aged 17 and someone aged 18. Anyone who has ever written a program<br />

knows that using if statements is error prone, so it is advisable to investigate this particular<br />

region of the data. This is the same as recognizing that data values at the edges of the<br />

partitions are worthy of inclusion in the testing. There<strong>for</strong>e we create two additional tests:<br />

Test number Data Outcome<br />

3 17 cannot vote<br />

4 18 can vote<br />

In summary, the rules <strong>for</strong> selecting test data <strong>for</strong> black box testing using equivalence<br />

partitioning are:<br />

1. partition the input data values<br />

2. select representative data from each partition (equivalent data)<br />

3. select data at the boundaries of partitions.<br />

In the last program, there is a single input; there are four data values and there<strong>for</strong>e<br />

four tests. However, most programs process a number of inputs. Suppose we<br />

wish to test a program that displays the larger of two numbers, each in the range<br />

0–10,000, entered into a pair of text boxes. If the values are equal, the program displays<br />

either value.<br />

Each input is within a partition that runs from 0 to 10,000. We choose values at<br />

each end of the partitions and sample values somewhere in the middle:<br />

first number: 0 54 10,000<br />

second number: 0 142 10,000<br />

Now that we have selected representative values, we need to consider what combinations<br />

of values we should use. Exhaustive testing would mean using every possible<br />

combination of every possible data value, but this is, of course, infeasible. Instead, we<br />

use every combination of the representative values. So the tests are:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!