Skip to content

checkpoint() fails to validate if function is called 0 times or never #463

Closed
@vikz95

Description

@vikz95

Hi, I opened an issue about how to check if mockObject expectations are met directly from the main tokio test task (#461). The problem was that panics in subtasks are not propagated to the main task and the test succeeds when it should fail.

It was suggested to use mockObject.checkpoint()

My mockObject function is called once. If I change the expected times that it's called to a higher value, like times(2), when I invoke checkpoint() the test fails as it should.
But if I change the value to times(0) or if I use never() the test succeeds..

Is this a bug? Or is it an expected behaviour because checkpoint() is intended to be called mid test, so if the number of times the function is actually called is less than the expected, it's fine because the test is not yet complete and the function could still be called?

If it's the second case I think that it could be useful to have a similar method intended to be used at the end of the tests.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions