Mock Service Templates are common collections of Transactions and Parameter selections that you can reuse when you need to test against those Transactions. For example, for a login service, you might create a Template that includes a few Transactions required for negative testing. Then, when you need to test those scenarios, you can quickly provision a Mock Service based on that Template to test with.
Templates override the Transactions that are directly in a Mock Service, and are meant to be a more persistent way to add commonly grouped Transactions to a Mock Service on the fly.
- Create a Mock Service Template
- Create a Mock Service from a Mock Service Template
- Create a Mock Service Template from a Mock Service
Create a Mock Service Template
- Click Mock Services from the Mock Services tab.
- Click the Add button next to Mock Services Templates.
- Give the Template a meaningful name.
It's important to give meaningful names and descriptions, because when testers are using the Mock Services panel to add Mock Services to tests, they need to understand what might be relevant to their tests based on these values only.
- Select or create the associated Service. The Service is a representation of the underlying live service, and it serves as a container for the Transactions you will upload. If an existing Service contains Transactions that are needed for this Mock Service, select the existing Service.
To create a new Service:
- Click Select Service.
- Enter the name for your new Service and click Add Service.
- Click the arrow to the left of the Template name to edit Template details.
- Enter a description for the Template.
- (Optional) If the Transactions needed for the Template don't yet exist, drag a supported file type into the upload box. If the Transactions already exist in the Service you selected, skip to Step 10.
The Import Transactions dialog opens.
- Select the Service that you specified in the Service field next to the Template name.
- If you want to assign one or more tags to these transactions, type the tag name(s) in the Tags field and press Enter.
- Tags make Transactions easier to identify, especially within a large Service. You can provide tag definitions here to apply the defined tags to all imported Transactions. Or you can define tags at the Transaction level after import.
- To enter multiple tags, press Enter after each tag name.
- Click Import.
The imported Transactions appear in the Other Transactions in Your Catalog pane.
- Select the Transactions to include in the Template, and click the right arrow icon to move them to the Transactions in this Mock Service Template panel.
- Click the Parameters tab.
- In the No Matching Requests field, choose the correct logic for when a request against the Mock Service does not match any of the provided transactions. The request can either throw an error or be redirected to the live service.
- Set the Think Time in milliseconds to control the amount of time spent between when the Mock Service receives a request and returns a response. The default is 0, but you can update the field to simulate delayed responses.
- Click Save.
Create a Mock Service from a Mock Service Template
At any time after saving the Template, click Create Mock Service to the right of the Template name to dynamically provision a Mock Service that includes the transactions in the Template.
Create a Mock Service Template from a Mock Service
After you create a Mock Service with Transactions, you may realize that you need to reuse that Mock Service at a later date. Create a Template from the Mock Service to preserve its configuration for future use.
To create a Template from a Mock Service, mouse over a Mock Service in the Mock Services table and click the Camera icon:
A Template is created with the same configuration as the Mock Service.