The reason, as shown in Figure 2, is that
results of conditions in and and or expressions can mask or
block the evaluation of other conditions. For instance, if an
and condition is false, none of the subsequent conditions in
the expression need be evaluated. Likewise if an or condition
is true, none of the subsequent conditions need be evaluated.
Hence, errors in logical expressions are not necessarily
revealed by the condition-coverage and
decision/condition-coverage criteria.
A criterion that covers this problem, and
then some, is multiple-condition coverage. This criterion
requires that you write sufficient test cases that all
possible combinations of condition outcomes in each decision,
and all points of entry, are invoked at least once. For
instance, consider the following sequence of pseudocode.
NOTFOUND=TRUE; DO I=1 to TABSIZE WHILE
(NOTFOUND); /*SEARCH TABLE*/ ...searching
logic...; END
The four situations to be tested are:
- I<=TABSIZE and NOTFOUND is true.
- I<=TABSIZE and NOTFOUND is false (finding the entry
before hitting the end of the table).
- I>TABSIZE and NOTFOUND is true (hitting the end of
the table without finding the entry).
- I>TABSIZE and NOTFOUND is false (the entry is the
last one in the table).
|