Simulation

Overview

Simulations are JSON files that contains pairs of HTTP requests and their corresponding HTTP responses, also known as request/response pairs.

The simulation file, once created, defines what the API simulation will look like and how it will respond to requests. You load the simulation file into a Hoverfly service in order to have a real running API Simulation.

A simulation file consists of a number of request/response pairs. The request part defines "matchers" that you configure to match the pattern of an incoming HTTP request. For example your matcher might be configured to match on an incoming GET request with a path that matches a particular regular expression that you define. When a matcher makes a match, Hoverfly returns the corresponding response that is paired with that request matcher.

Hoverfly Cloud manages simulations created by you or your team (for Enterprise accounts) in one place.

We currently provides 4 convenient ways of creating a simulation:

A simulation is only a configuration file, you use it by importing it into a virtual service.

Key features

Hoverfly simulation supports these commonly used Service Virtualization features:

  • Strict or loose HTTP request matching based on URL, method, body and header combinations.

  • Build dynamic response using templating using handlebars syntax. Read more here.

  • Simulate different responses to the same request based on the current state of a service (Stateful Simulation).

  • Render data from a data-source using a provided key. Read more here.

  • Add fixed or lognormal delay to the response.

Hoverfly Cloud also provides an easy-to-use Simulation Editor to let you create/edit simulation data without any knowledge of the Hoverfly simulation schema.

The editor gives you auto-completion and suggestions for things like response status code, header names, request matchers and state keys. You can work with the JSON/XML/HTML body using the embedded code editor which provides syntax highlighting and validation. The code editor also supports auto-completion of templating functions, and automatic conversion of encoded body. Batch processing is possible with the global find-and-replace rules.

Last updated