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

Moves MockKExtension's unmockkAll behavior to the afterAll callback #739

Merged
merged 2 commits into from Nov 16, 2021
Merged

Moves MockKExtension's unmockkAll behavior to the afterAll callback #739

merged 2 commits into from Nov 16, 2021

Conversation

gmazzo
Copy link
Contributor

@gmazzo gmazzo commented Nov 9, 2021

This change is motivated by the comment I've dropped at #142 (comment).

MockKExtension is calling unmockkAll by default at the end of each test, which interferes with the @TestInstance(TestInstance.Lifecycle.PER_CLASS) configuration.

We discovered this issue after enabling junit.extensions.autodetection.enabled=true (by other rules, not this one) and all tests with cached mocks (per instance) started to fail because of the reset.

This PR moves the unmockkAll behavior to the afterAll callback, and also introduces a new @KeepMocks (and a mockk.junit.extension.keepmocks property) to allow disabling just this feature while keeping the others of MockKExtension.

@Raibaz
Copy link
Collaborator

Raibaz commented Nov 11, 2021

This looks ok to me, thanks a lot for sending this through!

Could you also add a paragraph about unmocking and @KeepMocks in the user guide, in the "Junit5" section?

Signed-off-by: Guillermo Mazzola <guillermo.mazzola@glovoapp.com>
@gmazzo
Copy link
Contributor Author

gmazzo commented Nov 13, 2021

This looks ok to me, thanks a lot for sending this through!

Could you also add a paragraph about unmocking and @KeepMocks in the user guide, in the "Junit5" section?

Done!

@Raibaz
Copy link
Collaborator

Raibaz commented Nov 14, 2021

Thanks a lot!

Not merging this right away as I want to make a release as soon as it's merged, otherwise the docs and the actual behavior of the library would not be the same.

Going to merge this ASAP though, probably some time next week.

@gmazzo
Copy link
Contributor Author

gmazzo commented Nov 16, 2021

Ready to merge then? I don't have merge rights

@Raibaz Raibaz merged commit 284da25 into mockk:master Nov 16, 2021
@gmazzo
Copy link
Contributor Author

gmazzo commented Nov 17, 2021

Thanks a lot!

Not merging this right away as I want to make a release as soon as it's merged, otherwise the docs and the actual behavior of the library would not be the same.

Going to merge this ASAP though, probably some time next week.

I'm very sorry, I didn't want to rush you into this with my "Ready to merge then? I don't have merge rights". I've commented while reviewing my "pendings" without refreshing the ticket first 🤦

@Raibaz
Copy link
Collaborator

Raibaz commented Nov 17, 2021

No worries, I was ready to release anyway :)

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