Test Plan Variables are key-value pairs configured in a Test Plan that can be referred to by scenarios in the Test Plan. When you want to have shared variables across scenarios in a Test Plan, such as User IDs or some environmental settings, Test Plan Variables will be useful.
Priority of Variables
As Autify has a mechanism of Passing Variables Between Tests, variables can be flexibly used at different levels. Before moving on to Test Plan Variables, let’s take a look at how these different kinds of variables work on Autify.
Variables referenced by scenarios can be defined as key-value pairs called Import Variables. When a Scenario with Import Variables is run in a Test Plan, variables will be looked up in the following order:
- Variables returned as Export Variables from the preceding scenario execution in the test plan
- Variables defined in the Test Plan (Test Plan Variables)
- Default Values of the Import Variables defined in the scenario
See also Passing Variables Between Tests.
Create a Scenario that refers to Test Plan Variables
To make it possible for a Scenario to refer to Test Plan Variables, you need to create a Scenario with Import Variables. For more details, see Set Import Variables.
Create variables in a Test Plan
Next, let’s create a Test Plan with Test Plan Variables. Go to Test Plan Details page and find “Test plan variables” section. Click “Add” button to create a new variable.
Input a key and a value for the variable, and click “Create” button. Make sure that the keys are the same as what you have as Import Variables in the Scenarios.
By repeating this process, you can create up to 50 Test Plan Variables in a Test Plan.
Run tests with variables
Now, let's take a look at how tests run with Test Plan Variables using the following example.
This Scenario imports
LAST_NAME as variables. The default value of
FIRST_NAME is "Foo", and that of
LAST_NAME is "Bar".
In the scenario,
LAST_NAME are used for Input steps.
This Test Plan has
LAST_NAME as Test Plan Variables. The default value of
FIRST_NAME is "Hatty", and that of
LAST_NAME is "Bee".
When the test is run individually by "Run Now", the Scenario will use the default values of Import Variables:
- FIRST_NAME =
- LAST_NAME =
On the other hand, when this Scenario is run in the Test Plan, the Test Plan Variables will be referred to.
- FIRST_NAME =
Hatty(test plan default value)
- LAST_NAME =
Bee(test plan default value)
Testing against different multiple environments
One of the common use cases of Test Plan Variables is to use different values against different test environments. This is very powerful when used with URL replacement feature. Let’s assume that we want to run the same test plans for a Production environment and Staging environment with different User IDs:
In this case, your goal can be achieved by the following:
- Create Scenarios that import the User ID as Import Variables
- Create a Test Plan for each environment, Production and Staging with
- URL replacement for the environment (Production/Staging)
- Test Plan Variable for User ID
This way, you can easily leverage your Test Plan to cover multiple environments with variables.
Test Plan for Staging environment
Test Plan for Production environment
We are looking forward to seeing what you will build with Test Plan Variables!