Test Plan Variables
  • 27 Nov 2023
  • 2 Minutes to read
  • Contributors
  • Dark
    Light

Test Plan Variables

  • Dark
    Light

Article Summary

Overview

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.

Use Variables

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:

  1. Variables returned as Export Variables from the preceding scenario execution in the test plan
  2. Variables defined in the Test Plan (Test Plan Variables)
  3. Default Values of the Import Variables defined in the scenario

Variables-en.png

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.

Screen Shot 2023-11-13 at 8.52.57.png

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.

Screen Shot 2023-11-12 at 21.20.48.png

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.

Screen Shot 2023-11-12 at 21.21.27.png

By repeating this process, you can create up to 50 Test Plan Variables in a Test Plan.

Screen Shot 2023-11-12 at 21.22.52.png

Run tests with variables

Now, let's take a look at how tests run with Test Plan Variables using the following example.

Scenario

This Scenario imports FIRST_NAME and LAST_NAME as variables. The default value of FIRST_NAME is "Foo", and that of LAST_NAME is "Bar".

Screen Shot 2023-11-21 at 1.16.57.png

In the scenario, FIRST_NAME and LAST_NAME are used for Input steps.

Screen Shot 2023-11-21 at 1.16.41.png

Test Plan

This Test Plan has FIRST_NAME and LAST_NAME as Test Plan Variables. The default value of FIRST_NAME is "Hatty", and that of LAST_NAME is "Bee".

Screen Shot 2023-11-22 at 17.47.46.png

Test results

When the test is run individually by "Run Now", the Scenario will use the default values of Import Variables:

  • FIRST_NAME = Foo (default value)
  • LAST_NAME = Bar (default value)

Screen Shot 2023-11-21 at 1.17.20.png

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)

Screen Shot 2023-11-21 at 1.17.50.png

Use Cases

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:

URL prefixUser ID
Productionhttps://prd.example.comprd@example.com
Staginghttps://stg.example.comstg@example.com

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

Screen Shot 2023-11-21 at 0.53.36.png

Test Plan for Production environment

Screen Shot 2023-11-21 at 0.55.39.png

We are looking forward to seeing what you will build with Test Plan Variables!


Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.