are here: Freetutes.com
Analysis and Design
White Box Testing
White box testing focuses on the internal functioning of the product.
For this different procedures are tested. White box testing tests the following
- Loops of the procedure
- Decision points
- Execution paths
For performing white box testing, basic path testing technique is used. We
will illustrate how to use this technique, in the following section.
Basis Path Testing
Basic path testing a white box testing technique .It was proposed by Tom McCabe.
These tests guarantee to execute every statement in the program at least one time
during testing. Basic set is the set of all the execution path of a procedure.
Flow graph Notation
Before basic path procedure is discussed, it is important to know the simple
notation used for the repres4enttation of control flow. This notation is known
as flow graph. Flow graph depicts control flow and uses the following constructs.
These individual constructs combine together to produce the flow graph for
a particular procedure
Sequence - Until
If - While
Basic terminology associated with the flow graph
Node: Each flow graph node represents
one or more procedural statements. Each node that contains a condition is called
a predicate node.
Edge: Edge is the connection between
two nodes. The edges between nodes represent flow of control. An edge must terminate
at a node, even if the node does not represent any useful procedural statements.
Region: A region in a flow graph is
an area bounded by edges and nodes. Cyclomatic complexity: Independent path is
an execution flow from the start point to the end point. Since a procedure contains
control statements, there are various execution paths depending upon decision
taken on the control statement. So Cyclomatic complexity provides the number of
such execution independent paths. Thus it provides a upper bound for number of
tests that must be produced because for each independent path, a test should be
conducted to see if it is actually reaching the end point of the procedure or
Cyclomatic Complexity for a flow graph is computed in one of three ways:
The numbers of regions of the flow graph correspond to the Cyclomatic complexity.
Cyclomatic complexity, V(G), for a flow graph G is defined as
V(G) = E – N + 2
where E is the number of flow graph edges and N is the number of flow graph nodes.
Cyclomatic complexity, V(G), for a graph flow G is also defined as
V(G) = P + 1
Where P is the number of predicate nodes contained in the flow graph G.
Example: Consider the following flow graph
Region, R= 6
Number of Nodes = 13
Number of edges = 17
Number of Predicate Nodes = 5
Cyclomatic Complexity, V( C) :
V( C ) = R = 6;
V(C) = Predicate Nodes + 1
V( C)= E-N+2
Deriving Test Cases
The main objective of basic path testing is to derive the test cases for the
procedure under test. The process of deriving test cases is following
From the design or source code, derive a flow graph.
Determine the Cyclomatic complexity, V(G) of this flow graph using any of the
formula discussed above.
· Even without a flow graph, V(G) can be determined by counting the number
of conditional statements in the code and adding one to it.
Prepare test cases that will force execution of each path in the basis set.
· Each test case is executed and compared to the expected results.
Graph matrix is a two dimensional matrix that helps in determining the basic
set. It has rows and columns each equal to number of nodes in flow graph. Entry
corresponding to each node-node pair represents an edge in flow graph. Each edge
is represented by some letter (as given in the flow chart) to distinguish it from
other edges. Then each edge is provided with some link weight, 0 if there is no
connection and 1 if there is connection.
For providing weights each letter is replaced by 1 indicating a connection.
Now the graph matrix is called connection matrix. Each row with two entries represents
a predicate node. Then for each row sum of the entries is obtained and 1 is subtracted
from it. Now the value so obtained for each row is added and 1 is again added
to get the cyclomatic complexity.
Once the internal working of the different procedure are tested, then the testing
for the overall functionality of program structure is tested. For this black box
testing techniques are used which are discussed in the following pages.
Previous Page | Contents
| Next Page >>