> For the complete documentation index, see [llms.txt](https://help.autify.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.autify.com/nocode-web/en/autify-university/advanced/variables/test-plan-variables.md). Agents can also search and read this documentation through its [MCP server](https://help.autify.com/~gitbook/mcp).

# Test Plan Variables

## 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](https://help.autify.com/nocode-web/en/autify-university/advanced/variables/passing-variables-between-tests.md), 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

![](https://1964297753-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVdZPTgwISYb3LhjgKnw6%2Fuploads%2Fgit-blob-1cf776b3fccfcb820d2520029290b92caaeb8f94%2FVariables-en.png?alt=media)

See also [Passing Variables Between Tests](https://help.autify.com/nocode-web/en/autify-university/advanced/variables/passing-variables-between-tests.md).

### 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](https://help.autify.com/nocode-web/en/autify-university/advanced/variables/passing-variables-between-tests.md#set-import-variables).

![](https://1964297753-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVdZPTgwISYb3LhjgKnw6%2Fuploads%2Fgit-blob-4635924baaec5cf238095cdf8870d477db020e48%2FScreen%20Shot%202023-11-13%20at%208.52.57.png?alt=media)

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

![](https://1964297753-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVdZPTgwISYb3LhjgKnw6%2Fuploads%2Fgit-blob-c33a76ebe4573c03fea8670491ce86ffc521a690%2FScreen%20Shot%202023-11-12%20at%2021.20.48.png?alt=media)

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.

![](https://1964297753-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVdZPTgwISYb3LhjgKnw6%2Fuploads%2Fgit-blob-a6b388261a4222cbd1edbe02f38cad56b1e371da%2FScreen%20Shot%202023-11-12%20at%2021.21.27.png?alt=media)

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

![](https://1964297753-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVdZPTgwISYb3LhjgKnw6%2Fuploads%2Fgit-blob-645224abf26114b008167bdcd1e2c4f7b50c6f59%2FScreen%20Shot%202023-11-12%20at%2021.22.52.png?alt=media)

### 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".

![](https://1964297753-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVdZPTgwISYb3LhjgKnw6%2Fuploads%2Fgit-blob-cf3b95a7ccfcf7c1d5705d8039a351e45b118eea%2FScreen%20Shot%202023-11-21%20at%201.16.57.png?alt=media)

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

![](https://1964297753-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVdZPTgwISYb3LhjgKnw6%2Fuploads%2Fgit-blob-a93103e21afcc71bfe1f5a5e23c6dc557f7507bd%2FScreen%20Shot%202023-11-21%20at%201.16.41.png?alt=media)

#### 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".

![](https://1964297753-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVdZPTgwISYb3LhjgKnw6%2Fuploads%2Fgit-blob-c40851e3d887aaafd4c931b97a8f639e7a9e998a%2FScreen%20Shot%202023-11-22%20at%2017.47.46.png?alt=media)

#### 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)

![](https://1964297753-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVdZPTgwISYb3LhjgKnw6%2Fuploads%2Fgit-blob-e4ec37bb482e7c14adc1279cd23dc96e04108861%2FScreen%20Shot%202023-11-21%20at%201.17.20.png?alt=media)

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)

![](https://1964297753-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVdZPTgwISYb3LhjgKnw6%2Fuploads%2Fgit-blob-67e2e0d6b76358dd9ae6611bb8c700307985479c%2FScreen%20Shot%202023-11-21%20at%201.17.50.png?alt=media)

## 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 prefix                | User ID           |
| ---------- | ------------------------- | ----------------- |
| Production | <https://prd.example.com> | <prd@example.com> |
| Staging    | <https://stg.example.com> | <stg@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

![](https://1964297753-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVdZPTgwISYb3LhjgKnw6%2Fuploads%2Fgit-blob-7b95fcef09ac342e3e5febe54259ddb59d9ecbbd%2FScreen%20Shot%202023-11-21%20at%200.53.36.png?alt=media)

#### Test Plan for Production environment

![](https://1964297753-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVdZPTgwISYb3LhjgKnw6%2Fuploads%2Fgit-blob-03c48139bcdd57277b98a544114c969fc197920d%2FScreen%20Shot%202023-11-21%20at%200.55.39.png?alt=media)

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


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://help.autify.com/nocode-web/en/autify-university/advanced/variables/test-plan-variables.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
