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

Support resetting state between tests #49

@xordspar0

Description

@xordspar0

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions