Mock Service Configurations

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 ${} format. For example, to reference a custom port, use ${config.port}.

Tip: Configurations are similar to Using Test Data With Service Virtualization. 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.

  1. Go to the Service Virtualization tab and open the Configurations tab.
  2. For each configuration, click Create New Configuration.
  3. Enter a Name for the configuration, for example staging, development, testing.
  4. (Optional) Enter a Description that informs team members of the purpose of this configuration.
  5. For each property, click Add Property and enter a Name and its Value.
  6. Click Save.

Now you can use the values and enable this configuration for a Mock Service.

mock service configurations tab

Use the Configuration Values

  1. Go to the Service Virtualization tab and open the Mock Service.
  2. For each Mock Service, identify the respective hard-coded values.
  3. Replace the hard-coded values with custom properties in ${} 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.

  1. Go to the Service Virtualization tab and open the Mock Service.
  2. If the Mock Service is running, click Stop.
  3. (Optional) Edit the configuration values on the Configurations tab if needed.
  4. Open the Mock Service definition and select the desired configuration.
  5. Click Run Mock Service to restart the Mock Service with the new profile.

mock service configurations tab