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.
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.
Â