Create simulations
Simulations are a set of virtual services and connections that you can use instead of real services that are unavailable in your test environment. A virtual service needs connections to communicate with a service. This means that data is sent to or received from the destination or location that you've specified as the connection in your simulation, such as an URL, port, etc.
You can create simulations in the following ways:
-
In the simulation registry, where you manually enter all the required message elements of your simulation.
-
Capture the traffic of 2 services that are communicating with each other and save this traffic as a simulation in your simulation registry.
-
In learning mode, by forwarding requests to the real service and recording its responses. This way, the simulation captures the real service’s behavior and updates automatically as it learns new interactions.
-
From an API test that you save as a simulation in your simulation registry.
-
In a text editor or an Integrated Development Environment (IDE) of your choice, where you manually enter all required message elements.
Create a simulation file
Your simulation file needs the following elements:
-
Use these top-level elements of a simulation file to define the behavior of a simulation:
Main element
Description
Example
connections
Connections that are required for communication with a service.
includes
Links to other simulation files. You can reuse simulations in multiple other simulations, so you don't have to redo your work. The file path can be absolute or relative to the current schema location.
C:\my_simulations\test.yaml
name
Name of the simulation.
My simulation
resources
Resources that you want to share between different services.
schema
Version name of the schema applied to the simulation YAML file. This property is mandatory and the value must be SimV1.
SimV1
services
Virtual services that you want to simulate.
Apply messages, connections, or services which you can reuse within virtual services. Reference these messages and connections with the basedOn property, and services with the use property.
myMessage,
myConnection
myService
-
The simulation file must include one or more connections to communicate with a service. Use connection properties to define them.
-
Use message properties to define the content of your outgoing messages.
-
Use resource properties in your simulation file to reference a resource, such as a data structure.
-
Use service properties to specify the order in which you want to send or receive messages.
-
Use steps to define the process of a service.
-
Define rules to select which messages you want to send or receive.
-
Find out which values you can use to define your properties and how to specify them.
The simulation file is a YAML file and follows YAML patterns. For information on how to work with YAML files, see the YAML documentation.
Explore our simulation file examples to see how you can use the properties in different scenarios.