Loop Testing in Software Testing


This article explains Control Structure Testing and Loop Testing. Control Structure Testing is a part of white box testing, it includes the following methods:

  1. Condition Testing
  2. Loop Testing
  3. Data validation testing
  4. Path testing

Here I am explaining Loop Testing.

Loop Testing

Loops are fundamental for the vast majority of all algorithms implemented in software. Loop Testing is a white box testing technique that entirely concentrates on the validity of loop constructs.

Types of Loops

Loops are of the following four types:

  • Simple Loop
  • Nested Loops
  • Concatenated Loops
  • Unstructured Loops

Simple Loops

Simple Loops.jpg

A simple loop is tested in the following way:

  1. Skip the entire loop.
  2. Make 1 pass through the loop.
  3. Make 2 passes through the loop.
  4. Make x passes through the loop where x<y, n is the maximum number of passes through the loop.
  5. Make "y","y-1","y+1" passes throug the loop where "y" is the maximum number of allowable passes through the loop.

Nested Loop

Nested Loop.jpg

A nested loop is tested in the following way:

  1. A nested loop starts at the innermost loop.
  2. For the innermost loop, conduct a simple loop test.
  3. Work outward.
  4. Continue until the outermost loop has been tested.

Concatenated Loops

Concatenated Loop.jpg

To test concatenated loops the procedure is:

If the loops are independent then test them as simple loops or else test them as nested loops.

Unstructured Loops

Unstructured Loops.jpg

These are unstructured loops. To test them one needs to restructure the design to reflect the use of the structured programming constructs.