White Box Testing
White box testing is also called structural testing because it uses the internal structure of the program to derive the test cases. It is a selective testing technique that focuses on the procedural logic and therefore can also be applied at the detailed design stage to a procedural design.
The three white box test techniques are: Basic Path Testing, Graph Matrices, and Loop Testing. For the first two techniques, the source code or PDL is first presented as a logic flowgraph or control flowgraph. In this case, we used the basic path testing as described in the next section.
Basic Path Testing
Objectives of Basic Path Testing:
Transform flowchart/PDL/NS chart to Flow Graph
Identify all paths for testing
To ensure maximum path coverage, we need enough test cases to ensure that:
Every statement in a component has been executed at least once.
Every decision (branch or case statement) has been executed on its true and false side.
Cyclomatic Complexity
The cyclomatic complexity, denoted V(G) is a software metric that provides a quantitative measure of the logical or control complexity of an algorithm or program. The data complexity is not taken into account.
The cyclomatic complexity may be determined in any one of the following three ways:
V(G) = Edges - Nodes + 2
V(G) = No.of regions of the flowgraph
V(G) = Predicate Nodes + 1
Example
The following PDL describes the operations summary given in the Main Menu (Parent) Form:
Procedure LoadMainMenu
Begin
While invalid user id and password 1
Show first page
Check user id and password 2
Endwhile 3
While choice != exit 4
Show menu page
Read user choice 5
If choice = display schedule 6
Show schedule 7
Endif
If choice = display history 8
Show history 9
Endif
If choice = add/search goods 10
While choice != back to menu 11
Show goods inventory page 12
Endif
If choice = client 13
While choice != back to menu 14
Show client page 15
End while
End if
If time = transaction done 16
Update schedule, history and inventory 17
Endif
Endwhile
End
The corresponding Flow Graph is given as follows:
![]()
![]()
In the above case, calculation of the cyclomatic complexity was done as follows:
V(G) = Edges - Nodes + 2 = 20 - 12 + 2 = 10
V(G) = No.of regions of the flowgraph = 10
V(G) = Predicate Nodes + 1 = 9 + 1 = 10
Example of Linearly Independent paths (not all):
1 2 1 3 Ext
1 3 4 5 7 9 12 15 17 3 Ext
1 3 4 5 6 7 8 9 10 A1 12 13 A2 15 16 17 3 Ext
1 3 4 5 7 9 10 11 10 A1 12 13 4 13 A3 15 17 3 Ext
The graph matrix is given below:
|
|
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
A1 |
11 |
12 |
13 |
A2 |
14 |
15 |
16 |
17 |
EXT |
|
1 |
1 | 1 | ||||||||||||||||||
|
2 |
1 | |||||||||||||||||||
|
3 |
1 | 1 | ||||||||||||||||||
|
4 |
1 | |||||||||||||||||||
|
5 |
1 | 1 | ||||||||||||||||||
|
6 |
1 | |||||||||||||||||||
|
7 |
1 | 1 | ||||||||||||||||||
|
8 |
1 | |||||||||||||||||||
|
9 |
1 | 1 | ||||||||||||||||||
|
10 |
1 | 1 | ||||||||||||||||||
| A1 | 1 | |||||||||||||||||||
|
11 |
1 | |||||||||||||||||||
|
12 |
1 | 1 | ||||||||||||||||||
|
13 |
1 | 1 | ||||||||||||||||||
| A2 | 1 | |||||||||||||||||||
|
14 |
1 | |||||||||||||||||||
|
15 |
1 | 1 | ||||||||||||||||||
|
16 |
1 | |||||||||||||||||||
|
17 |
3 | |||||||||||||||||||
|
EXT |
The following PDL describes the operations summary given in the Log On Form:
Procedure Login
Begin
Input userID and password 1
If userID is correct Then 2
If password is correct Then 3
Output message logon success 5
Else
Output error message wrong password 6
Endif 7
Else 4
Output error message wrong userID
Endif 8
End
The corresponding Flow Graph:

In the above case, calculation of the cyclomatic complexity was done as follows:
V(G) = Edges - Nodes + 2 = 9 - 8 + 2 = 3
V(G) = No.of regions of the flowgraph = 3
V(G) = Predicate Nodes + 1 = 2 + 1 = 3
Linearly independent paths:
1 2 3 5 7 8
1 2 3 6 7 8
1 2 4 8
The graph matrix is given below:
|
|
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
|
1 |
|
1 |
|
|
|
|
|
|
|
2 |
|
|
1 |
1 |
|
|
|
|
|
3 |
|
|
|
|
1 |
1 |
|
|
|
4 |
|
|
|
|
|
|
|
1 |
|
5 |
|
|
|
|
|
|
1 |
|
|
6 |
|
|
|
|
|
|
1 |
|
|
7 |
|
|
|
|
|
|
|
1 |