Stateful mocking vs. Scenarios
WireMock Cloud provides scenarios as a way to create advanced, pre-defined testing conditions. Alternatively, you can use our dynamic states feature for truly stateful mocking that allows you to define operations and context to use in dynamic test sessions concurrently.Example
To implement the above case, you would declare that the stub returning the empty list is only matched when the scenario state is “Started”, while the stub returning the list with one item is only matched when the scenario state is “First item added”. Start by creating the empty list stub, which is matched only when the scenario named “To do list” is in the “Started” state:

Testing
First, make aGET
request to fetch the list, which should be empty. You should be able to do this any number of times
without the result changing:
POST
a new item (it actually doesn’t matter what the request body contains, since we didn’t specify a body matcher in the stub):