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 . 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.
-
Add Conditions to your , that determines if a particular Test Step is to be run or not.
-
At run time the actual values of variables are replaced in the expression, and is evaluated for true or false.
Rules for specifying Condition
-
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. -
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. -
Following values in Condition will evaluate to TRUE:
true or TRUE or no value
(blank), whereasfalse or FALSE or 0(zero)
evaluate to FALSE. -
Following operators are supported,
>,<,=,<>,>=,<=, AND, OR
. -
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>