Wiremock: Api to reset the state of a specific scenario in Wiremock?

Created on 10 Jan 2018  路  6Comments  路  Source: tomakehurst/wiremock

Let's say a scenario has 3 states and I want to go back to the first state if for some reasons my code (which uses the wiremock's stub) executed 2 states successfully but failed to trigger the 3rd state.

I want to go back to the first state only after some set specific time. If the 3rd state doesn't get triggered within this set time then go back to state 1.

Feature request

Most helpful comment

I've labelled this a feature request. If you'd like to raise a PR for this, it'll likely happen much sooner.

All 6 comments

I found a way to reset the states of all scenarios i.e, WireMock.resetAllScenarios() but couldn't find a way to reset state of any specific scenario. @tomakehurst by any chance you want to include this feature?

I've labelled this a feature request. If you'd like to raise a PR for this, it'll likely happen much sooner.

Tried to hack around this feature by setting the last request to "newScenarioState" : "Started", but this randomly assignes the state to another previous state. If it was possible to set new scenario state back to "started" it would be easy to reset scenarios?

@Nyeng https://github.com/tomakehurst/wiremock/pull/1046 should be the Feature Request you are looking for, right?

Is there any news about the PR getting merged? Or is there any workaround at the moment to set the scenario to an specific state?

@kurimin the workaround is to create a stub on a URL that doesn't exist in the API you're mocking, and give it a nextScenarioState of STARTED. Then you just make a request that matches the stub whenever you want to reset the individual scenario.

Was this page helpful?
0 / 5 - 0 ratings