Whitebox Testing1 (Recovered)
Whitebox Testing1 (Recovered)
Defined as a path through the program from the start node until
the end node that introduces at least one new set of processing
statements or a new condition (i.e., new nodes)
Must move along at least one edge that has not been traversed
before by a previous path
Basis set for flow graph on previous slide
Path 1: 1-11
Path 2: 1-2-3-4-5-10-1-11
Path 3: 1-2-3-6-8-9-10-1-11
Path 4: 1-2-3-6-7-9-10-1-11
The number of paths in the basis set is determined by the
cyclomatic complexity
CYCLOMATIC COMPLEXITY
Provides a quantitative measure of the logical complexity of a program
Defines the number of independent paths in the basis set
Provides an upper bound for the number of tests that must be conducted to
ensure all statements have been executed at least once
Can be computed three ways
1. The number of regions
2. V(G) = E – N + 2, where E is the number of edges and N is the number
of nodes in graph G
3. V(G) = P + 1, where P is the number of predicate nodes in the flow
graph G
Results in the following equations for the example flow graph
Number of regions = 4
V(G) = 14 edges – 12 nodes + 2 = 4
V(G) = 3 predicate nodes + 1 = 4
DERIVING THE BASIS SET AND TEST
CASES
main()
{
int x;
if (x==42)
{ ...}
}
EXISTENCE POSSIBILITIES OF A VARIABLE
Variables that contain data values have a
defined life cycle. They are created, they
are used, and they are killed
Three possibilities exist for the first occurrence
of a variable through a program path:
~d: the variable does not exist (indicated by the ~),
then it is defined
~u: the variable does not exist, then it is used (u)
~k: the variable does not exist, then it is killed or
destroyed (k)
EXISTENCE POSSIBILITIES OF A VARIABLE
The first is correct. The variable does not exist and then
it is defined.
The second is incorrect. A variable must not be used
before it is defined.
The third is incorrect. Destroying a variable before it is
created is indicative of a programming error.
SEQUENCE OF POSSIBILITIES