Conditional Execution of Test Cases
This video tutorial demonstrates, how you may perform conditional execution of test cases:
With the help of Condition property of a test case, you can write test cases which must only execute, when a particular condition is met. A "Condition" property has been introduced with vREST v2.4.2 in "Details" sub-tab of a test case.
The property works according to following rules:
- If the condition property is not specified (i.e. is Empty), then the test case will be executed.
- else if the condition property for the test case is set, then the test case execution will be decided based on the value evaluated for the condition.
- If the value evaluated for the condition is truthy, then the test case will be executed andÂ
- if the value evaluated for the condition is falsy, then test case execution will be skipped.
- Note: for more information on javascript truthy / falsy values, please read this sitepoint article.
This functionality is useful in creating dependency between test cases. e.g. if you want to decide the execution of a test case based on any previous test case, then you may read extracting variables from test case results.
Â
The property can accept the following values:
- String values
- All string values will be treated as truthy.
- Number values
- All numbers except zero will be treated as truthy.
- boolean values
- true will be truthy
- false will be falsy
- null
- null will be treated as falsy value
- vREST variables
- If variables are specified as value for the condition property, then their value will be evaluated first then decision will be taken according to their value.
- vREST utility methods
- If utility methods are specified as value for the condition property, then their value will be evaluated first then decision will be taken according to their return value.
Â
- If utility methods are specified as value for the condition property, then their value will be evaluated first then decision will be taken according to their return value.
Note:
If you want to prevent execution of a test case based on the results of previous test case then follow this guide link .
Screenshots:
- Screenshots demonstrating the values for the condition property for the test caseÂ
- Screenshots demonstrating the results if the condition is not met for the test case
Â
Â
Â