Extracting variables from test case results

Variables can also be extracted from Test Case's results and can be used in subsequent HTTP requests (test cases). To extract the variable's values from test case's results, please follow the steps below:

  • Expand the test case from which you want to extract variables
  • Go to "Variable Extractor" >> "Variables from Results"
  • Provide the variable name in which you want to extract the test case result

A test case result is a JSON object with the following keys:

  • isPassed: Value of this key will be true if the test case is passed otherwise the value will be false.
  • isExecuted: Value of this key will be true if the test case is executed successfully irrespective of it's result otherwise the value will be false.
  • isRunnable: Value of this key will be true if the test case is marked as runnable otherwise the value will be false.
Note: Iteration result variable is an array of test case results for each iteration inside the loop.
Use Case: This functionality is useful in extracting the result of a test case into a variable then based on the result, execution of subsequent test cases can be controlled.

Let us take an example, how we can extract a variable from test case result:

  • Suppose we have two test cases, first one creates a resource on server and second test case updates that resource on server. If the first test case fails then we want to prevent the execution of second test case.

     

  • Now extract the result of first test case into a variable say "tcResult" as shown below:

     

  • Now, use the extracted result of first test case as a condition of any subsequent test case.
     
     

  • Now, if we execute the test cases and if the first test case fails then second test case becomes not runnable and will not be executed.

    Â