Adding a Mock Service to a Test

As a tester, you may need to configure your tests to:

  • Test functionality, like negative scenarios or other uncommon behavior that is difficult to reproduce using the live service.
  • Test against a service that might not be available.
  • For other use cases, see Service Virtualization Use Cases and Capabilities.

In the past, perhaps you worked with a center of excellence or other group to obtain mocks to cover your specific testing scenario, or you built and managed them yourself using another tool. With Service Virtualization fully integrated into BlazeMeter, it is a much simpler process to associate a Mock Service with your test. The test creation page includes a Mock Services configuration that lets you quickly see the available Mock Services, choose what you need based on your test requirements, and obtain the endpoint for the Mock Service.

Add Mock Services to Tests

The Mock Services configuration is available for performance and functional tests.

Follow these steps:

  1. Access the Configuration tab for a performance or GUI functional test.
    test configuration tab
  2. Find the Mock Services configuration and click the slider to open it.
    mock services configuration
  3. Click the + button and select Add Mock Service.
  4. Select a Mock Service from the Mock Service Name drop-down list.
    service selection menu
    The Mock Services are categorized by Service. Services represent the underlying live service. For example, for testing AWS integration in your application, the Service name might be AWS Service, and the Mock Service might be a mock of one part of that service, such as AWS S3. These names are all controlled by the user who created the Mock Services.
    After you select the Mock Service, its information appears on the same row. If the Status is Stopped, the Mock Service is not running, and any tests run against that Mock Service will fail. Run the Mock Service from the Mock Services tab to be able to use it in a test.
    If the Status is Running, your Mock Service is ready, and the endpoint for the Mock Service is available.
    aws service used in test

    Note: You can add multiple Mock Services as needed. When you delete a Mock Service from this pane, it only deletes it from that test, not from the product.

  5. (Optional) Select the Template that contains the Transactions and Parameters you want to load into the Mock Service.
    Templates offer common groupings of Transactions. For example, a Template could contain the Transactions required to test key negative scenarios for the AWS S3 service.

    Note: If you do not selected a template, the Mock Service will run with the transactions that it was configured with.

  6. With your selections in place, you should then verify if the application has been configured to test against the Mock Service. If not, copy the endpoint and make the necessary change at the application level to ensure that the test runs against the Mock Service instead of the live service.
    When you run the test, the data from the Template is loaded into the Mock Service at runtime, and it overrides any existing Transactions that were directly in the Mock Service.
    If you want to load a Mock Service into a test without using a Template, add the Mock Service directly in the Taurus script and not in the UI.

Add Individual Mock Services and Tags

Click the Service Virtualization tab to select individual Mock Services and to add tags to a single test.

individual mock services and tags

The yaml construct will be updated as the following example:

yaml for individual mock services and tags