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.
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:
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