Rather than hard-coding recurring configuration values in a Mock Service, transaction, or processing action, you can define environment variables for Mock Services to use at runtime, such as a different server and port for testing and staging. Use the Configurations tab to create custom configurations to store your attribute-value pairs. To use a configuration value, refer to it in ${config.name}
format. For example, to reference a custom port, use ${config.port}
.
Tip: Configurations are similar to Introduction. Use test data if you want to reuse the same values at Service level or in Performance and Functional tests. Use Mock Service configurations to provide common values at the Mock Service's workspace level if you don't have the requirement to share them with tests.
Create a Mock Service Configuration
Before deploying a Mock Service, create and select the desired configuration.
- Go to the Mock Services tab and open the Configurations tab.
- For each configuration, click Create New Configuration.
- Enter a Name for the configuration, for example staging, development, testing.
- (Optional) Enter a Description that informs team members of the purpose of this configuration.
- For each property, click Add Property and enter a Name and its Value.
- Click Save.
Now you can use the values and enable this configuration for a Mock Service.
Use the Configuration Values
- Go to the Mock Services tab and open the Mock Service.
- For each Mock Service, identify the respective hard-coded values.
- Replace the hard-coded values with custom properties in
${config.name}
format.Tip: Click the Copy button next to the property name to copy the correct syntax into the clipboard.
Enable or Change a Mock Service Configuration
You cannot change the active configuration while the Mock Service is running.
- Go to the Mock Services tab and open the Mock Service.
- If the Mock Service is running, click Stop.
- (Optional) Edit the configuration values on the Configurations tab if needed.
- Open the Mock Service definition and select the desired configuration.
- Click Run Mock Service to restart the Mock Service with the new profile.
0 Comments