Skip to content
This repository has been archived by the owner on Sep 25, 2023. It is now read-only.

Support resetting state between tests #49

Open
xordspar0 opened this issue Jan 10, 2020 · 0 comments
Open

Support resetting state between tests #49

xordspar0 opened this issue Jan 10, 2020 · 0 comments

Comments

@xordspar0
Copy link

This is related to another bug, which is that if you declare an expectation with .once(), the test can pass even if that endpoint never gets called.

In this scenario, there will be a mocked response already in the queue when we move on to another test. It's a mistake to expect mocked endpoints to be called an then not call them, but DefaultMockServer should also provide a method that can be called to reset state and ensure that no state carries over between tests.

Here's an example of this situation: https://github.com/fabric8io/kubeflix/blob/v1.0.28/turbine-discovery/src/test/groovy/io/fabric8/kubeflix/turbine/TurbineDiscoveryTest.groovy

Say we add a fifth test to the end of that spec. At the beginning of our test, there are 3 mock responses in the queue before the code of the test case even runs. Here's one of them:

https://github.com/fabric8io/kubeflix/blob/v1.0.28/turbine-discovery/src/test/groovy/io/fabric8/kubeflix/turbine/TurbineDiscoveryTest.groovy#L94-L97

However, in the then section there is an expectation that verifies that the endpoint is never called: https://github.com/fabric8io/kubeflix/blob/v1.0.28/turbine-discovery/src/test/groovy/io/fabric8/kubeflix/turbine/TurbineDiscoveryTest.groovy#L108

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant