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:

  1. If the condition property is not specified (i.e. is Empty), then the test case will be executed.
  2. 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.
    1. If the value evaluated for the condition is truthy, then the test case will be executed and 
    2. if the value evaluated for the condition is falsy, then test case execution will be skipped.
    3. 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:

  1. String values
    1. All string values will be treated as truthy.
  2. Number values
    1. All numbers except zero will be treated as truthy.
  3. boolean values
    1. true will be truthy
    2. false will be falsy
  4. null
    1. null will be treated as falsy value
  5. vREST variables
    1. 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.
  6. vREST utility methods
    1. 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:

  1. Screenshots demonstrating the values for the condition property for the test case

     
  2. Screenshots demonstrating the results if the condition is not met for the test case