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
-
To open the Endpoints & Environments editor, select Configure Environments from a drop-down list on the ReadyAPI toolbar:
-
In the editor, click to add an environment:
-
Specify a name for the new environment and click OK.
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. -
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:
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 | Adds a new environment. | |||
Remove | Deletes the selected environment. | |||
Rename | Renames the selected environment. | |||
Clone | Creates a copy of the selected environment. | |||
Sort | Sorts environments alphabetically. | |||
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.
|
|||
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:
-
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:
-
Select the needed environments. Hold Ctrl or Shift to select several environments.
-
Click .
-
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