4. 167
2.1.4.1 Simple loops
2.1.4..2 Concatenated loops
2.1.4.3 Nested loops
2.1.4.4 Unstructured loop
Figure (1): Types of loops
2.1.4.1 Simple loop testing: For better coverage of statement within the loop there should be test
cases that
1. Skip loop entirely, so that the situation of the termination condition true before starting
the loop is tested.
2. Exercise the level (only one pass through the loop, two pass through the loop, or m pass
through the loop where m n and n is total iteration) to check all possible “ normal “
operations of the loop.
3. Try to cover all boundary conditions (n-1, n , n+1 pass through the loop)
2.1.4.2 Nested loop testing: For better coverage of statement with in the loop Bezier suggest the
following approach [1].
1. Start at inner most loop. Set all other loops to minimum values.
2. Conduct simple loop test for the inner most loop, while holding the outer loop at
(minimum iteration parameters) . Add other tests for out of range or excluded the values.
3. Work outward conducting test for the next loop but keeping all other outer loop at
minimum values and other loops to “typical” values.
4. Continue until all loops have been tested.
6. Fig (2): Flow Graph
(a) Number of regions in the flow graph
V(G)= R (regions )
Where V(G) is a cyclomatic complexity
As shown in figure(2) there are 2 regions, so the cyclomatic complexity [7] for flow graph
is V(G)=2