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
- An existing API Testing Project and Test. For details on how to create them, see API Testing Quickstart.
- Recommended: review Creating Reusable Variables and Snippets with the Vault
Creating Environments
Once you have a variable, you can override it if needed using the Environment feature.
There are multiple ways to create and access Test environments:
From the Environments
- From within a Project, go to the Environments section.
- Click Create Environment.
- Enter a name for your environment, then click Save when finished.
- From here, you can:
- Add variable(s) manually by clicking New Entry > Enter Key and Value pairs > Confirm.
- Import an existing environment by clicking Import > Choose File (accepted file types are Postman, .json, .csv).
- Add variable(s) manually by clicking New Entry > Enter Key and Value pairs > Confirm.
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
- From within a Project, go to any of the following sections: Tests, Compose, HTTP Client, or Load Test.
- Click the Environments dropdown list (defaults to No environment).
- Select Add item.
- Enter a name for your environment, then click Confirm.
- Click Create variable, enter Key and Value pairs, then click Confirm.
- When you're finished adding variables, click the Cross icon.
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.
- From within a Project, go to any of the following sections: Tests, Compose, HTTP Client, or Load Test.
- Click the Environments drodropdown list down (defaults to No environment), then select the name of the environment you want to use.
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.