TestOwl LogoTestOwlDocs

How to Use Variables in TestOwl Tests

Variables are reusable values that can be referenced throughout your Test Cases, and Flows. Instead of hardcoding the same value in multiple places, define it once and reuse it everywhere.

Why use Variables?

Using Variables makes your tests easier to maintain. Update the value once, and every Test Case or Flow that references it automatically uses the new value.

Common use cases

Variables are useful for values that change over time or are reused across multiple tests.

Some common examples include:

  • Application URLs
  • Usernames
  • Email addresses
  • Product IDs
  • Search terms
  • Order numbers
  • Environment-specific values

For sensitive values such as passwords, API keys, or access tokens, use Secrets instead.

Creating a Variable

To create a Variable:

  1. 1
    Open Data Config from the sidebar.
  2. 2
    Select the Variables tab.
  3. 3
    Click New Variable.
  4. 4
    Enter a unique Variable Name, such as API_BASE_URL.
  5. 5
    Choose its Type — Static for a fixed value, or Dynamic to generate a fresh value every run (see Test Data Generator).
  6. 6
    Enter the Value.
  7. 7
    Choose the Scope: Global, or Specific Environments and pick which ones.
  8. 8
    Save the Variable.

You can also Duplicate an existing Variable from the table to create a similar one quickly.

Create Variable

Using Variables

Variables can be used in any step that supports them.

Reference a Variable using double curly braces:

text
{{apiBaseUrl}}

Most supported fields include a Select from Variable or Secret button, allowing you to insert Variables without typing their names manually.

Using Variables

Variable scope

Variables can be configured with different scopes.

Global Variables

A global Variable is available throughout the entire project and can be used in every Test Case, Flow, and Environment.

Examples include:

  • Company name
  • Default language
  • Shared email address

Environment-specific Variables

Environment-specific Variables override the global value for a particular Environment.

This is useful when different environments require different values, such as:

  • Base URLs
  • Test accounts
  • Database identifiers
  • API endpoints

For example:

EnvironmentapiBaseUrl
Developmenthttps://dev.example.com
Staginghttps://staging.example.com
Productionhttps://example.com

Editing Variables

Updating a Variable automatically updates every Test Case and Flow that references it.

There's no need to edit individual tests when a shared value changes.

Deleting Variables

Deleting a Variable moves it to the Recycle Bin instead of permanently removing it.

Variables remain in the Recycle Bin for 15 days and can be restored during that time, after which they are permanently deleted.

Before deleting a Variable

Before deleting a Variable, make sure it isn't referenced by existing Test Cases or Flows. Removing a Variable may cause those tests to fail until the reference is updated.

Best practices

  • Use Variables instead of repeating the same value across multiple tests.
  • Give Variables descriptive names such as apiBaseUrl or adminUsername.
  • Store sensitive information in Secrets, not Variables.
  • Keep Environment-specific values inside Environment-specific Variables.
  • Delete unused Variables regularly to keep your project organised.

Next steps

Last updated:

Maintained by the TestOwl product team.