-
Notifications
You must be signed in to change notification settings - Fork 38.2k
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
MockReset
strategy is no longer honored for @MockitoBean
and @MockitoSpyBean
#33941
Comments
@MockitoBean
before performing tests@MockitoBean
is always reset before tests, ignoring MockReset.AFTER
strategy
@MockitoBean
is always reset before tests, ignoring MockReset.AFTER
strategyMockReset
strategy is no longer honored for @MockitoBean
and @MockitoSpyBean
I confirm it's fixed now, thank you @sbrannen |
As a follow up to commit 0088b9c, this commit introduces an integration test which verifies that a spy created via @MockitoSpyBean using the MockReset.AFTER strategy is not reset between the refresh of the ApplicationContext and the first use of the spy within a @Test method. See gh-33941 See gh-33986
@sbrannen , I'm afraid this isn't fixed yet. I made a pull request with your suggestion and it just doesn't build and it throws the same error: jesperancinha/jeorg-spring-test-drives#737 |
@jesperancinha, you only updated the dependency for In other words, you are still running your test against Thus, you will at the very least need to update the dependency for |
Thanks for your response @sbrannen ! You did only mention |
Hi @jesperancinha,
You're welcome.
I actually did not mention any specific artifact. Though I see that the Spring Framework Artifacts wiki page consistently uses So, I'll update that wiki page to provide greater clarity.
Thanks for letting us know that your issue is resolved with the snapshots.
Snapshots are only meant for trying out a fix locally before the official next release. More importantly, it is not recommended to use snapshot dependencies in production. So, you should definitely set a reminder or create an issue in your issue tracker to make sure you stop using snapshot dependencies. Regards, Sam |
FYI: I addressed that in #34002. |
The test fails with
@MockitoBean
but works fine with Spring Boot's@MockBean
.I think it's caused by
@MockitoBean
resetting the mock before tests automatically.The text was updated successfully, but these errors were encountered: