Folding repetition into a loop
How to use loop control actions to handle iterative processes.
In theMy streamliningtest module you created previously, create a new test case:
Place your cell pointer on a line somewhere below the existing set of action lines (but before the
FINAL
section, if any).Click Create New Test Case on the toolbar.
A test case line similar to the following is inserted.
In the second column of the new line, assign the test case an ID ofTC 02(if not already set to that value).
Press
Tab
to advance to the next column, and provide a description for your test case, such asloop it
.
Copy the first two local variable action lines from Test Case
TC 01
(not from theINITIAL
section), and paste them lines into the new test case.Under your new action lines, enter a repeat action in the left-most column.
Note that an
until
action is automatically inserted several lines below therepeat
action. Together, these two actions form a loop in which all action lines appearing between them are repeatedly executed until a condition is satisfied. That condition is specified in the until action’s condition to stop argument.Insert additional blank rows after the
repeat
action, so that therepeat
and until lines are at least nine rows apart. (Note that you can pressCtrl+I
to insert rows above the cell pointer.)This allows two action lines to be inserted into the loop.
Select one of the report action lines from Test Case
TC 01
, copy it, then paste it under the repeat action line ofTC 02
.Under that line (but before the
until
action line), enter the following action line:variable value local variable car price # car price + 5000
With this line, during execution, the local variable car price is incremented with each iteration of the
repeat
/until
loop, achieving the same thing as each of the last two local variable lines of the first test caseTC 01
.Finally, enter the expression
# car price > 30000
as the condition to stop argument of the until action.This comparison expression serves as the terminating condition of the
repeat
/until
loop. It is evaluated each time theuntil
statement is executed. If false, execution returns to the first action line under the repeat. If true, the loop is exited, and execution continues with the next action line under theuntil
.Your test case should now resemble the following:
Execute Test Case 02 of your test.
With your test displayed in the editor, do the following:
Click Execute on the toolbar.
The
Execute Test
dialog box appears.In the Test Modules panel, expand the tree.
Ensure that only the check box for test caseTC 02is selected.
Click Execute.
The status bar (at the bottom left of the TestArchitect window) indicates the stages of the test as it progresses.
In the test results, click the View detailed results per test line link to open the detailed test lines on a web browser.
On the Result Details tab, view the output of the report action lines, which are identical to those of test case
TC 01
.
Given the small size of TC 01
(only three redundant report actions), it does not pose much of a problem. But if it were required to produce more report lines for a wider range of car prices (at a constant incremental change in value), the test would need to grow in proportion to the number of reports required. By contrast, the same can be accomplished in Test Case TC 02
without any additional action lines – only an adjustment of its repeat/until loop’s terminating condition would be required.