Environments and Presets

One of the key aspects of creating meaningful tests is being able to run them against different environments, to make sure that the upcoming release will pass the tests designed for the production release.

To do so, API Fortress introduced 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:

hamOr in the composer, clicking on “environments”:

ham2

Simply overriding variables

In the override panel, you can type in which variables you want to override and activate the preset:

overBy doing so, you will be overriding the variables for the current session, as long as the preset is activated. This override will be performed to your session only.

Saving the environment

overOnce 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 the 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.

selIn 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:

{
  "Content-Type":"application/json",
  "payload":"{}",
  "params":{"apif_env":"staging"}
}