Structured Testing - McCabe and Associates
Structured Testing - McCabe and Associates
Structured Testing - McCabe and Associates
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
A program with cyclomatic complexity 5 has the property that no set of 4 paths will suffice for<br />
testing, even if, for example, there are 39 distinct tests that concentrate on the 4 paths. As discussed<br />
in section 2, the cyclomatic complexity gives the number of paths in any basis set. This<br />
means that if only 4 paths have been tested for the complexity 5 module, there must be, independent<br />
of the programming language or the computational statements of the program, at least one<br />
additional test path that can be executed. Also, once a fifth independent path is tested, any further<br />
paths are in a fundamental sense redundant, in that a combination of 5 basis paths will generate<br />
those further paths.<br />
Notice that most programs with a loop have a potentially infinite number of paths, which are not<br />
subject to exhaustive testing even in theory. The structured testing criterion establishes a complexity<br />
number, v(G), of test paths that have two critical properties:<br />
Several studies have shown that the distribution of run time over the statements in the program<br />
has a peculiar shape. Typically, 50% of the run time within a program is concentrated within<br />
only 4% of the code [KNUTH]. When the test data is derived from only a requirements point of<br />
view <strong>and</strong> is not sensitive to the internal structure of the program, it likewise will spend most of<br />
the run time testing a few statements over <strong>and</strong> over again. The testing criterion in this document<br />
establishes a level of testing that is inherently related to the internal complexity of a program’s<br />
logic. One of the effects of this is to distribute the test data over a larger number of independent<br />
paths, which can provide more effective testing with fewer tests. For very simple programs<br />
(complexity less than 5), other testing techniques seem likely to exercise a basis set of paths.<br />
However, for more realistic complexity levels, other techniques are not likely to exercise a basis<br />
set of paths. Explicitly satisfying the structured testing criterion will then yield a more rigorous<br />
set of test data.<br />
5.2 Intuition behind structured testing<br />
The solid mathematical foundation of structured testing has many advantages [WATSON2].<br />
First of all, since any basis set of paths covers all edges <strong>and</strong> nodes of the control flow graph, satisfying<br />
the structured testing criterion automatically satisfies the weaker branch <strong>and</strong> statement<br />
testing criteria. Technically, structured testing subsumes branch <strong>and</strong> statement coverage testing.<br />
This means that any benefit in software reliability gained by statement <strong>and</strong> branch coverage testing<br />
is automatically shared by structured testing.<br />
32<br />
1. A test set of v(G) paths can be realized. (Again, see section 9.1 for discussion of the<br />
more general case in which actual complexity is substituted for v(G).)<br />
2. <strong>Testing</strong> beyond v(G) independent paths is redundantly exercising linear combinations<br />
of basis paths.