Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better detection of unnecessary stubbing #825

Merged
merged 2 commits into from May 24, 2022

Conversation

PHaroZ
Copy link

@PHaroZ PHaroZ commented May 18, 2022

Automatic verification confirmation introduces a new mechanism that ensure that all declared stubs are verified. This is cool but doesn't exactly match which is requested in #558 and exposed in mockito doc

This PR add a new checkUnnecessaryStub() method, and its companion JUnit annotion @CheckUnnecessaryStub.

The main usecase of this feature is to avoid the verify steps when all stubs are done with precision and every stubs are used only once.

Copy link
Collaborator

@Raibaz Raibaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pretty cool, thanks a lot!

I just have a doubt about a minor change, but apart from that LGTM.

@Raibaz
Copy link
Collaborator

Raibaz commented May 19, 2022

Still, I really don't know why tests are failing though.

Would you please take a look? Thanks again!

@PHaroZ
Copy link
Author

PHaroZ commented May 20, 2022

This seems due to the fact I put InvocationAnswer as a key of a HashMap, the hashCode of Answer try to be computed but it fails for some reason thaht I don't understand well (linked to io.mockk.impl.recording.states.CallRecordingState#cancelAndThrowBadRecordingState ).

I changed the implementation of my feature and get rid of the HashMap. All tests should be green :)

@Raibaz
Copy link
Collaborator

Raibaz commented May 24, 2022

Thanks again!

@Raibaz Raibaz merged commit 42cbe60 into mockk:master May 24, 2022
@PHaroZ PHaroZ deleted the checkUnnecessaryStub branch May 30, 2022 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants