Environments

Applies to ReadyAPI 3.57, last modified on December 18, 2024

About Environments

In ReadyAPI, an environment is a set of parameters that match certain configuration for your tests. An environment includes API endpoints, authentication profiles for REST, SOAP, and GraphQL services, database connection settings, custom project properties, and parameters of connection to JMS servers.

By switching an environment, you can quickly change properties of your test without the necessity of changing them manually.

Note: Environments can include only project properties. Test suite properties and lower-level properties will not be available.

Create environment

  1. To open the Endpoints & Environments editor, select Configure Environments from a drop-down list on the ReadyAPI toolbar:

    Environments in ReadyAPI: Configure Environments

    Click the image to enlarge it.

  2. In the editor, click Add to add an environment:

    ReadyAPI: Creating the first environment

    Click the image to enlarge it.

  3. Specify a name for the new environment and click OK.

    ReadyAPI: Creating an environment
    In ReadyAPI 1.9 or earlier, using services or interfaces with identical names can cause issues. Please update to ReadyAPI 3.57 to make sure your services have unique identifiers.
  4. Populate the environment with the needed endpoints, properties, JDBC connections, and JMS servers.

    Tip: You can copy or move custom properties to other environments. Besides that, you can copy the entire environment to another project.

Configure environment

To configure environments, select Configure Environments from a drop-down list on the toolbar:

Environments in ReadyAPI: Configure Environments

Click the image to enlarge it.

Change API endpoints, project properties, JDBC connections, and JMS servers for different environments by using the corresponding tabs:

Note: The availability of tabs depends on the services and connections added to your project. For example, if your project has a REST service and a JMS connection, you will see REST and JMS tabs.

Toolbar

Use the buttons on the Endpoints & Environments editor toolbar to add, remove, modify environments, or copy them to another project.

Icon Option Description
Add Add Adds a new environment.
Remove Remove Deletes the selected environment.
Rename Rename Renames the selected environment.
Clone Clone Creates a copy of the selected environment.
Sort Sort Sorts environments alphabetically.
Move Up
Move Down
Move Up
Move Down
Moves the selected environment up or down in the list. The order of environments will also be changed in the Environments drop-down.
Tip: You can also drag an environment to change its position in the list.
Copy Copy environment

Copies the selected environment to another project. To learn more, see below.

Switch between environments

To switch between environments, use one of the following commands:

  • Use the drop-down list on the control bar:

    ReadyAPI: Selecting an environment

    Click the image to enlarge it.

  • Double-click an environment in the Endpoints & Environments editor.

  • Right-click an environment in the Endpoints & Environments editor, and select Set Active.

  • Use the <project name>.setActiveEnvironment(<environment name>) code line in the setup or teardown script, or in the Groovy script test step:

    Groovy

    // Replace the project and environment names with those you need

    def proj = testRunner.testCase.project.workspace.getProjectByName("Sample Project")

    proj.setActiveEnvironment("Test Environment")

Set environments in command line runners

You can also force ReadyAPI to switch the environment while running tests with the functional test runner, performance test runner, or security test runner:

  • In GUI – On the Overrides tab, select the environment you need in the Environments drop-down list.

    Note: If you need to override the Endpoint, Username, and Password values, do this with the -e, -u, and -p command-line arguments. See Command-Line Arguments for details.
  • In command line – Specify the environment you need by using the -E argument, for example:

    "-ETest Environment"

Copy environments to another project

ReadyAPI copies environment values (API endpoints and the needed authorization profiles, custom project properties, JDBC connections, and JMS servers). To copy environments to another project:

  1. Select the needed environments. Hold Ctrl or Shift to select several environments.

  2. Click .

  3. Select the project to which you want to copy environments.

To learn what ReadyAPI will do if the target project contains an element with the same name, see the following table:

Element type If the element exists If the element does not exist

API

ReadyAPI copies the API’s endpoints and the needed authorization profiles.

ReadyAPI does not copy the API’s endpoints.

Authorization profile

ReadyAPI does not change the authorization profile in the target project. The related endpoints use the authorization profile specified in the target project.

ReadyAPI copies the authorization profile.

Custom project property

ReadyAPI overrides the value for the environment with the same name as the copied one.

ReadyAPI copies the property.

JDBC connection

ReadyAPI overrides values for the environment with the same name as the copied one.

ReadyAPI does not copy the element.

JMS server

See Also

Testing APIs
Starting ReadyAPI Tests by Using Command-Line Runners

Watch the video
 
Highlight search results