Loop Testing: Dr. D. P. Mohapatra
Loop Testing: Dr. D. P. Mohapatra
Dr. D. P. Mohapatra
Loop Testing
• Loop testing viewed as an extension to
branch coverage.
1. Simple Loops
Figure-A Figure-B
1. Simple Loops
• Check whether you can bypass the loop or not. If the test case for
bypassing the loop is executed and, still you enter inside the loop,
it means there is a bug.
• Check whether the loop control variable is negative.
• Write one test case that executes the statements inside the loop.
• Write test cases for a typical number of iterations through the
loop.
• Write test cases for checking the boundary values of maximum &
minimum number of iterations defined (say min and max) in the
loop. It means we should test for min, min+1, min-1, max-1, max,
and max+1 number of iterations through the loop.
2. Nested Loops
Nested Loops Cont …
• When two or more loops are embedded, it is called
a nested loop.
• If we adopt the approach of simple tests to test the
nested loops, then the number of possible test cases
grows geometrically.
• The strategy is to start with the innermost loops
while holding outer loops to their minimum values.
• Continue this outward in this manner until all loops
have been covered.
3.Concatenated Loops
Concatenated Loops
• Two loops are concatenated if it is possible to reach
one after exiting the other, while still on a path from
entry to exit.
• If the two loops are not on the same path, then they
are not concatenated.
• The two loops on the same path may or may not be
independent.
• If the loop control variable for one loop is used for
another loop, then they are concatenated, but nested
loops should be treated like nested only.
4.Unstructured Loops
• This type of loop is really impractical to test
and they must be redesigned or at least
converted into simple or concatenated loops