Software testing is an essential part of the Software Development Life Cycle (SDLC) to ensure the quality of a software product. Out of the several software testing techniques employed, we will discuss the loop testing technique.
The loop testing technique is used to validate all loops in a program. The validation of a loop entails the following:
In simple loop testing, a simple loop control structure (either for
, while
, or do-while
) is tested to ensure that it terminates at some point.
for (initialization; condition; increment) {
statement(s);
}
Nested loop testing is applied when at least one loop is nested inside another. We make sure that the outermost loop terminates by varying the iterations and conditions in the inner loops.
do {
while(condition2) {
statement(s);
}
} while(condition1);
Concatenated loop testing is applied when loops are in series and their conditions are dependent upon the same variable, initialized for the first loop.
do {
statement(s);
} while(condition1);
while (condition2) {
statement(s);
}
Unstructured loop testing is applied on a combination of nested and concatenated loops.
do {
while(condition2) {}
while(condition3) {}
} while(condition1);
Free Resources