Imposter can simulate failure types to enable you to test adverse scenarios, such as the connection being closed without receiving a response.
Failures can be injected via configuration or using a script driven approach.
The failure takes effect after any request processing has completed (scripts, plugins etc.) but before the response is sent.
Note Failures can also be combined with performance simulation effects. For example to simulate a delay followed by a closed connection.
The supported failure types are:
|Failure type||Effect||Configuration value|
|Empty response||Send an empty HTTP response||
|Close connection||Close the connection before sending a response||
fail option in configuration:
# ... resources: - method: GET path: /example1 response: # send an empty HTTP response fail: EmptyResponse - method: GET path: /example2 response: # close the connection before sending a response fail: CloseConnection
If using Scripting, use the
To send an empty response:
To close the connection:
You will see log entries similar to the following:
15:39:09 INFO i.g.i.s.CharacteristicsService - Simulating EmptyResponse failure for GET http://localhost:50204/example1