Condition Expression for Test Steps

In order to selectively use a Test Step of a Test Script at run time, use Condition field in your Test Script > Test Steps Applet. This Condition field takes simple expression and evaluated using ECMAScript compliant expression engine, at run time for each Test Step. If the expression evaluates to true, the Test Step is run, else it is skipped.

Use Condition expression to run or skip a Test Step at run time. Default value is blank, and it evaluates to True.

  1. Add Conditions to your Test Script > Test Steps, that determines if a particular Test Step is to be run or not.

  2. At run time the actual values of variables are replaced in the expression, and is evaluated for true or false.

Note: Syntax of expression is important and no prior validation of expression is performed.
Note: By default, if Condition field is blank, then the Test Step is not skipped.

Rules for specifying Condition

  1. Max length of field is 500. Ensure that the variable name does not have spaces.

    For example, variable @Test Variable is invalid, but @TestVariable or @testvariable or @test_variable are valid.

  2. Single space is the delimiter between the operands and operators used in condition expression. For example, @test > 10, @name = 'abc' OR @name = 'xyz'.

    Note: Text values to be enclosed within single quotes, as in the examples. Double quotes are not supported.
  3. Following values in Condition will evaluate to TRUE: true or TRUE or no value (blank), whereas false or FALSE or 0(zero) evaluate to FALSE.

  4. Following operators are supported, >,<,=,<>,>=,<=, AND, OR.

  5. Ensure the variables used in Condition are initialized with appropriate values, else the script fails with an error.

    Examples for Condition:

    • @env = 'DEV'

    • @env = 'UAT'

    • @conf > 0 AND @conf < 50

To initialize variables before a Test Script starts to run, use Parameters applet on Test Execution (or add Parameters section in unitconfig.xml for single Test Script Play from Test Scripts View). Add Name and Value pairs.

For example: To initialize a variable @balance with value 100, add a Parameter with name as balance and value of 100. Framework creates variables for each of the Name in Parameters applet, and initializes with corresponding Value. Such parameters or variables can be directly used in Test Step Condition and/or in Data Set Condition expression for comparison or input value.

<PARAMETERS>
	<PARAMETER>
	       <NAME>env</NAME>
	       <VALUE>DEV</VALUE>
	</PARAMETER>
	<PARAMETER>
	       <NAME>ROI</NAME>
	       <VALUE>20</VALUE>
	</PARAMETER>
</PARAMETERS>