WhiteBox Testing - Basis Path Testing
WhiteBox Testing - Basis Path Testing
WhiteBox Testing - Basis Path Testing
In fig. B each circle, called flow graph node, represent one or more procedural statement.
A sequence of process boxes and decision diamond can map into a single node.
The arrows on the flow graph, called edges or links, represent flow of control and are
parallel to flowchart arrows.
An edge must terminate at a node, even if the node does not represent any procedural
statement.
Areas bounded by edges and nodes are called regions. When counting regions, we
include they are outside the graph as a region.
When compound conditions are encountered in procedural design, flow graph becomes
slightly more complicated.
When we translating Program Design Language segment into flow graph, separate
node is created for each condition.
Each node that contains a condition is called predicate node and is characterized by two
or more edges comes from it.
Independent program paths or Cyclomatic complexity :
An independent path is any path through the program that introduces at least one new set
of processing statement or new condition.
For example, a set of independent paths for flow graph:
Path 1: 1-11
Path 2: 1-2-3-4-5-10-1-11
Path 3: 1-2-3-6-8-9-1-11
Path 4: 1-2-3-6-7-9-1-11
Note that each new path introduces a new edge.
The path 1-2-3-4-5-10-1-2-3-6-8-9-1-11 is not considered to e an independent path
because it is simply a combination of already specified paths and does not traverse any
new edges.
Test cases should be designed to force execution of these paths (basis set).
Every statement in the program should be executed at least once and every condition
will have been executed on its true and false.
Example:
Referring to the flow graph, the cyclomatic complexity can be computed using each of
the algorithms just noted:
Graph Matrices:
A graph matrix is a square matrix whose size (i.e., number of rows and columns) is equal
to the number of nodes on the flow graph.
Each row and column corresponds to an identified node, and matrix entries correspond
to connections (an edge) between nodes.
Each node on the flow graph is identify by numbers, while each edge is identify by
letters.
The link weight provides additional information about control flow. In its simplest
form, the link weight is 1 (a connection exists) or 0 (a connection does not exist).
Each letter has been replaced with a 1, indicating that a connection exists (this graph
matrix is called a connection matrix).
In fig.( connection matrix) each row with two or more entries represents a predicate
node.
Example:
Function fn_delete_element (int value, int array_size, int array[])
{
1 int i;
location = array_size + 1;
2 for i = 1 to array_size
3 if ( array[i] == value )
4 location = i;
end if;
end for;
Example has:
Independent Paths:
1. 1, 9
2. 1, 2, 3, 8, 1, 9
3. 1, 2, 4, 5, 7, 8, 1, 9
4. 1, 2, 4, 6, 7, 8, 1, 9
Cyclomatic Complexity of 4;