Previous Topic: Configure the Next StepNext Topic: Import Test Cases


Branching and Looping in a Test Case
Branching in a Test Case

Branching in a test case is done using assertions.

Any number of assertions can be applied to a test step. Every assertion has a condition that evaluates to true or false. The first assertion for which the assertion condition is satisfied gets fired, and that changes the path of the workflow. In many steps, a default error condition is automatically created as an assertion to failure. When creating assertions, it is best to be consistent, and always branch positive, or always negative.

Assertions are described in detail in Adding an Assertion.

Looping in a Test Case

Loops are created when a test step downstream from a specified test step sends control to the test step that started the flow, as in a loop. What is important is the ability to come out of the loops. To break conditionally out of a loop (like a "while" loop in programming), set assertions on a test step that participates in the loop.

Use a data set to achieve a loop that executes a given number of times or until specific data is exhausted (like a "for" or "foreach" loop in programming). A data set is used to assign values to one or more properties a finite number of times. The next step that is executed after the data set is exhausted is specified with the data set definition. You can use this step to break the loop.

For example: if a data set contains 20 rows of users to log in to a system, you can create a loop to run the login step for each row in the data set. Alternatively, a numeric counting data set can be used to cause a specific step to execute a fixed number of times.

A single step can call itself, and loop over a data set. Several steps can run in a loop, using the data from a data set. The loop is accomplished when the final step in the group of steps points to the first step in the group.

Data sets are described in detail in Data Sets.