This video tutorial demonstrates, how you may perform conditional execution of test cases:
<iframe width="560" height="315" src="https://www.youtube.com/embed/uM4oKJ40kws?list=PLmua155_WrDyoe7dYDB3lCfh-UK4XicT6?ecver=1" frameborder="0" allowfullscreen></iframe>
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.
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 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 you want to prevent execution of a test case based on the results of previous test case then follow this guide link .
- 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