One of the key aspects of creating meaningful tests is being able to run them against different environments to ensure that the upcoming release will pass the tests designed for the production release.
For that reason, API Fortress offers the “Environments” feature.
An “environment” is a collection of override variables. An override variable is a variable that will replace the value of a variable that has been hardcoded within the Vault or the test itself, during a predefined session.
You can access the feature in the “tests list” by clicking the “hamburger menu” icon:
Or access the feature in the Composer by clicking on “environments”:
Simply Overriding Variables
In the override panel, you can type in which variables you want to override, and activate the preset:
By doing so, you will be overriding the variables for the current session for as long as the preset is activated. This override will be performed in your session only.
Saving the Environment
Once your Preset is ready and you are willing to save it for later use, you can click on the “save” button and give it a name. The Preset will be associated with the current project and will be available to you and other users.
Activating a Saved Environment
Once your environment is saved, you can activate it by choosing it from the “environments” dropdown that will show up by clicking on the arrow-down to the right of the environments icon.
In this example, we named the environment “staging”.
To disable the environment and go back to defaults, just select “None”.
Using a Saved Environment via API
When using the API by invoking a test execution, you can have API Fortress load an environment based on its name.
To do so, just provide the special variable “apif_env” in the params section, and provide the name of the environment you want to load, as in: