Creating mock services manually is a time-consuming work. There is a way MockMotor can do that for you.
MockMotor as a MITM
MockMotor can be placed between the client application and the real backend. MockMotor then can review the traffic and create mock responses as appropriate, in a semi-automatic mode.
To achieve that, a forwarding mock response should be placed into a mock service. The forwarding response sends the requests to the real backend and the responses to the client, but it can also record the traffic, creating mock responses or mock accounts.
Then, the client is pointed to the mock service instead of the real backend, and the test scenarios are executed. After that, the mock service contains several generated mock responses, and in some cases can mock all the traffic immediately and without the help of mock backend.
More often, however, some adjustment of the generated mocks is required. Still, it may save an enormous amount of time.
When a Forward URL is provided, and the
Record Response As Mock is enabled for a response, the reply that came
from the real backend service is not only sent to the consumer but is also recorded as a mock.
This allows to record the traffic in a test environment and automatically generate mock services to support that environment.
The recorded mock uses as many of the request parameters as possible to provide the exact match:
The mock saves the response values:
This is the default option. The reply from the backend service is not recorded.
This option is to make sure the new mock doesn’t break the current test flow.
The newly created mock is placed below (after) the forwarding mock, and hence is not active - the forwarding mock intercepts all traffic. When the test flow is completed, you need to move the recorded mock to its proper place in the list manually.
Record and Activate
The newly created mock is placed above (ahead of) the forwarding mock. The mock is in effect immediately and will handle the next matching request, even within the same test flow.
Read Recording SOAP/XML Traffic to record mocks per operation or a test account.
Read Recording HTTP/REST Traffic to record mocks with query string parameters or parameters in URL.
Read Recording Mock Accounts to record multiple mock accounts instead of multiple mock responses.