Capture modeΒΆ

Capture mode is used for creating API simulations.

Note

Hoverfly cannot be set to Capture mode when running as a webserver (see Hoverfly as a webserver).

../../../_images/capture.mermaid.png

In Capture mode, Hoverfly (running as a proxy server - see Hoverfly as a proxy server) intercepts communication between the client application and the external service. It transparently records outgoing requests from the client and the incoming responses from the service API.

Most commonly, requests to the external service API are triggered by running automated tests against the application that consumes the API. During subsequent test runs, Hoverfly can be set to run in Simulate mode, removing the dependency on the real external service API. Alternatively, requests can be generated using a manual process.

Usually, Capture mode is used as the starting point in the process of creating an API simulation. Captured data is then exported and modified before being re-imported into Hoverfly for use as a simulation.

By default, Hoverfly will ignore duplicate requests if the request has not changed. This can be a problem when trying to capture a stateful endpoint that may return a different response each time you make a request.

Using the stateful mode argument when setting Hoverfly to capture mode will disable the duplicate request check,
enabling you to capture sequences of responses and play them back in Simulate mode in order.

See also

This functionality is best understood via a practical example: see Capturing a stateful sequence of responses in the Tutorials section.