When switching from using @MockBean
annotation to @MockitoBean
in one of our projects, I have found some inconsistency between the two, if @PostConstruct
annotation is being used along with MockReset.NONE
. Here is the minimal reproductive example.
I suspect, that there was some change in the time when resetting the mocks happen - for some reason @MockitoBean
is being reset after @PostConstruct
is resolved, even though the MockReset.NONE
is being used for its configuration - this is not a case for @MockBean
.
Comment From: sbrannen
Hi @MateuszWicherski,
Congratulations on submitting your first issue for the Spring Framework! π
Fortunately, this has already been reported several times and was fixed in 6.2.1.
Adding the following to your build.gradle
file will allow your test to pass.
ext['spring-framework.version'] = '6.2.1'
In the future, please search the issue tracker for similar issues (included closed issues) before opening a new issue.
In light of the above, I am closing this as a:
- Duplicate of #33941
Regards,
Sam