Conditional/Environmental Test Data

Learn how environment-specific test data can make your tests more dynamic.

In Rainforest, you can tailor test data to the environment. Embed {{rainforest.environment_id}} in an existing dynamic data placeholder to specify the data to use for each environment. When the test runs, the placeholder is replaced with the environment ID.

This feature is useful when you require dynamic data that changes based on where your test runs. Without this feature, you’d have to replicate the test for each environment.

How It Works

This is best illustrated by providing a demonstration.

1. Find the environment ID.

Navigate to Settings > Sites and click on an environment to reveal its ID.

562

Locating your environment ID.

2. Specify the environment IDs in each column header.

In your dynamic data CSV, include the environment ID in the header for each column you want to associate with an environment. You can place the ID anywhere in the column title, as long as it’s consistent throughout.

In the following example, column B is associated with environment 557.

451

A dynamic data CSV file.

3. Upload your dynamic data CSV file.

Once the file has been uploaded, a preview appears, showing you the placeholders for each environment.

1754

A preview showing placeholders and environment IDs.

4. Add your conditional data to a test step.

  • When you write your test, use {{rainforest.environment_id}} to specify the environment ID for the run.
  • In the example below, the column var_{{rainforest.environment_id}} is called inside the {{test_conditional_vars}} placeholder file by writing:

    {{test_conditional_vars.var_{{rainforest.environment_id}}}}

1108

Specifying the environment ID.

Rainforest uses the column tied to the environment specified in the column header when running your test. In this example, environment “5098” was used and returned a value of “4c.”

1016

The returned value is “4c.”


If you have any questions, reach out to us at [email protected].