Skip to main content

Creating Environments for Tests

Our Environments feature provides you with a range of options to mix and match your Test settings.

If properly set up, any API Testing test can be run against any environment. This can be achieved by turning the URL and any other part into variables that can be overwritten using the environments.
 This allows you, for example, to set the default location as input and override those amounts with the environments feature without actually changing the Test.

The Environments section lets you change anything, not just environments. You can run the Test against a certain environment, using a different API key and data source.

What You'll Need​

Creating Environments​

Once you have a variable, you can override it if needed.

There are multiple ways to create and access Test environments:

From the Environments​

  1. From within a Project, go to the Environments section.
    access environment
  2. Click Create Environment.
  3. Enter a name for your environment, then click Save when finished.
    create environment
  4. From here, you can:
    • Add variable(s) manually by clicking New Entry > Enter Key and Value pairs > Confirm.
      create environment
    • Import an existing environment by clicking Import > Choose File (accepted file types are Postman, .json, .csv).
      create environment

The resulting environment (along with its defined variables) will now appear in each of your Tests as an option in the environment dropdown.

From a Project​

  1. From within a Project, go to any of the following sections: Tests, Compose, HTTP Client, or Load Test.
  2. Under Run Configuration, click the Environments dropdown (defaults to No environment).
  3. Select Add item.
  4. Enter a name for your environment, then click Confirm.
  5. Click Create variable, enter Key and Value pairs, then click Confirm.
  6. When you're finished adding variables, click the Close Environments Editor icon.
    create environment

This new environment will be selected by default in the dropdown.

Using Environments​

Once you've created an environment and added your variables, you can run your Test against that environment.

  1. From within a Project, go to any of the following sections: Tests, Compose, HTTP Client, or Load Test.
  2. Under Run Configuration, click the Environments dropdown (defaults to No environment), then select the name of the environment you created.
    result in tests

By activating an environment here, you will be able to hit a different variable (key/value pair) in your current session without actually changing your Test.

no environment​

If None (no environment) is selected, the Test will run using the values written as inputs in the test and the variables saved in the Vault.
result in tests

Loading Environments​

If you begin using environments heavily, the integration using the APIF API (or any CI/CD plugin) may become overly complex and β€œunfriendly,” as lots of data will need to be copied around.

For this reason, we have introduced a special override variable, apif_env, which tells our API to load a specific environment when invoking a test using the API. For example, to load the staging environment and all its override variables:

apif_env: staging

More Information​