Creating Stress Conditions - WinRunner

You can create stress conditions in test scripts that are designed to determine the limits of your application. You create stress conditions by defining a loop which executes a block of statements in the test script a specified number of times. TSL provides three statements that enable looping: for, while, and do/while. Note that you cannot define a constant within a loop.

For Loop

A for loop instructs WinRunner to execute one or more statements a specified number of times. It has the following syntax:

for ( [ expression1 ]; [ expression2 ]; [ expression3 ] )
statement

First, expression1 is executed. Next, expression2 is evaluated. If expression2 is true, expression3 is executed. The cycle is repeated as long as expression2 remains true. If expression2 is false, the for statement terminates and execution passes to the first statement immediately following.

For example, the for loop below selects the file UI_TEST from the File Name list in the Open window. It selects this file five times and then stops.

While Loop

A while loop executes a block of statements for as long as a specified condition is true. It has the following syntax:

while ( expression )
statement ;

While expression is true, the statement is executed. The loop ends when the expression is false.

For example, the while statement below performs the same function as the for loop above.

Do/While Loop

A do/while loop executes a block of statements for as long as a specified condition is true. Unlike the for loop and while loop, a do/while loop tests the conditions at the end of the loop, not at the beginning. A do/while loop has the following syntax:

do
statement
while (expression);
The statement is executed and then the expression is evaluated. If the expression is true, then the cycle is repeated. If the expression is false, the cycle is not repeated.

For example, the do/while statement below opens and closes the Order dialog box of Flight Reservation five times.


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

WinRunner Topics