Core concepts

Config

A Config, sometimes called Environment Variable or Global Variable, is a user-defined value that can be included (embedded, referenced) in many requests.

Configs enable our users to parameterize their requests. By parameterizing your requests, your requests become more maintainable, flexible, and easier to refactor in the future.

Using configs in requests

Use configs in requests by typing @ in any of the request form fields and selecting your config of choice from the list.

Create a new config

To create a new config, please follow the below steps:

  1. In the left navbar, click on the "Config" link.
  2. Click on the New Config button.
  3. Enter a name for your new config. You can use alphanumeric and hyphen for your config name.
  4. Select the type of config value.
  5. Provide a Default value for the new config, more about the Default value below.
  6. Leave the Environment Values section empty
  7. Click on Save to create the new config.

What is a Default Value?

As a technologist, oftentimes we interact with different versions of the same API in Localhost, Dev, Staging, UAT, and Production environments. There are scenarios in which a Config has the same value for all environments (e.g. user-agent). Rather than duplicating value for all environments, you can set the value using the Default Value field and use it against all of the environments.

What is an Environment Value?

An Environment Value is the opposite of the Default Value; it's unique to an Environment and will be used only when the request is sent to the parent environment.

An Environment Value allows you to define a dedicated and non-sharable config value for an Environment. The value will be only used against the target environment.

api-key config is a good example. You won't want to send the same API Key to both Dev, and Production instances of your API, but rather have a dedicated API key for each environment.

Use config values in requests

Once added, a Config can be referenced from within any request in your workspace. Currently, you can reference configs in Url, Request Header Value, Request Body, Response Body Validation, and Response Header Validation fields by typing @ and selecting one of the available configs.

Example

Let's say we got two versions of our API running on Dev (https://dev-api.my-co.com) and Prod (https://api.my-co.com) environments. To make our requests work against both environments, we should define a new Config called base-api-url and use it to construct the API endpoints.

  1. We pick base-api-url as a self-explanatory name for our config.
  2. Set Default Value to https://dev-api.my-co.com as we don't want requests to accidentally be sent to the production API.
  3. Set Environment Value for Prod environment to https://api.my-co.com.
  4. Set Environment Value for Dev environment to https://dev-api.my-co.com.
  5. Reference the base-api-url in the URL field of any available requests.

When sending requests that have used the base-api-url:

  • When no environment is selected, Testfully would use the Default Value (in this case https://dev-api.my-co.com).
  • When an environment is selected, Testfully would use the Environment Value for the selected environment.
Previous
Environments