The previous examples have only used Hoverfly in simulate mode. You can also run it in capture mode, meaning that requests will be made to the real service as normal, only they will be intercepted and recorded by Hoverfly. This can be a simple way of breaking a test’s dependency on an external service; wait until you have a green test, then switch back into simulate mode using the simulation data recorded during capture mode.

try(Hoverfly hoverfly = new Hoverfly(localConfigs(), CAPTURE)) {


    // do some requests here


By default Hoverfly captures multiple identical requests once only, but you can set the following config to enable stateful capture which should capture all requests sequentially.

Hoverfly hoverfly = new Hoverfly(localConfigs().enableStatefulCapture(), CAPTURE)