Mock Responses

Each mock service contains several of mock responses.

A mock response is a configured reply for a request.A response has a pre-configured payload (often scripted), HTTP status, delay and other properties that the calling application expects to receive to continue the test scenario.

In a simplest form, there is one mock response per service operation (SOAP operation or a REST URI+method).

In more complex cases there could be multiple responses per operation, one response handling multiple operations or even responses that do not correspond to any specific operation.

Response Selection

Responses in a mock service are organised as a list.

For each incoming request, each response is tried in turn, starting from the top of the list until one of them matches. If there are no responses left in the list and the match is still not found, MockMotor generates a HTTP 404 response.

For example, in the service above, the incoming request will be:

1 First checked for HTTP operation POST and the relative URL /pet.
2 Then either of these conditions fails to match, the request will be checked for HTTP POST and URL /user.
3 And so on.

Response selection can be also done by a SOAPAction header, first element of XML payload or even by script (XPath or Javascript).

Response Order Change

As already mentioned, the responses are matched in order of their appearance on the list.

To change the order of responses, drag and drop a response to its new place using the reorder control :

Adding a New Response

To add a new response, click on provide the required properties. The minimum is the Match Options and Response Payload. When the changes are complete, click “Save”.

More on response properties in:

1 General Info
2 Match Options
3 Accounts Selection
4 Payload
5 Forwarding to Real Backends
6 Properties
6 Attachments
7 Post-Updating Accounts
8 Saving Exchange
9 Change History
10 Debugging a Response
11 Response Cloning

Editing a Response

To edit a response, navigate to the Response page by clicking on either the edit icon in the response row or on the response name.

Cloning a Response

To create a copy of an existing response, navigate to the Response page and click “Clone”. Read more details on this here.

Deleting a Response

To delete a response, navigate to the Response page and click “Delete”. You will be asked for a confirmation.

Note that this operation is not reversible.

Disabling a Response

A safer alternative to deleting a response is to disable it.

Navigate to the Response page and click “Disabled” in the Status line, then click “Save”. The response will be disabled, i.e. ignored by any incoming requests.

The disabled responses are marked with strike-through text in the response list: