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 Mock Services 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 Mock Services functionality 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 panel 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 panel is available for performance and functional tests.
Follow these steps:
- Access the Configuration tab for a new or existing performance or GUI functional test.
- Find the Mock Services panel, and click the slider to open it.
- Click the + button and select Add Mock Service. For the Add Mock Services by Tag option, see Add Mock Services By Tag.
- Select a Mock Service from the Mock Service Name drop-down list.
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.
Note: You can add multiple Mock Services as needed. When you delete a Mock Service from this panel, it only deletes it from that test, not from the product. - (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. - 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 Mock Services to Tests in Bulk
You can add tags associated with multiple MAR-based Mock Services and assign these Mock Services to tests in bulk.
Note: You will only see this option if Service Virtualization and BlazeMeter Virtual Service Environments is enabled in your account.
Bulk Deploy MAR Files from Asset Catalog to a Location with Tags
To add Mock Services to tests in bulk, you first need to attach tags to MAR-based Mock Services.
Follow these steps:
- Navigate to Asset Catalog, MAR Files.
- Select the checkbox on the left for multiple MAR Files as needed.
Example: If you select three MAR files, three Mock Services will be created. - Click the Run button.
A dialog box opens. - Choose the location, add a new tag or select an existing tag.
- Click Deploy.
The Mock services were created with the tag that you assigned.
Add Mock Services By Tag
Prerequisite: Attach tags to MAR-based Mock Services. For more information, see Bulk Deploy MAR Files from Asset Catalog to a Location with Tags.
When you create Mock services with assigned tags, you can use these in Functional API testing.
Follow these steps:
- Enable Mock Service configuration on your test configuration page.
- Click the Add button. If the prerequisites are met, you will see two options. Select Add Mock Services by Tag.
A dialog box opens. - In the dialog box, select the tag that you associated with your MAR-based Mock Services
- Click Add.
The tag is added to your functional test and you can see the the Mock Services associated with it by expanding the row.
To remove the tag, click the Delete icon in the Actions column.
To add more tags, click the Add icon, select the Add Mock Services By Tag option and change your selection.
In the script mode, you can see that the yaml is updated with your selection.
Add Individual Mock Services and Tags
Click the Mock Services tab to select individual Mock Services and to add tags to a single test.
The yaml construct will be updated as the following example:
0 Comments