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

@MockitoBean behavior is not consistent with @MockBean when using @PostConstruct #34120

Closed
MateuszWicherski opened this issue Dec 19, 2024 · 1 comment
Assignees
Labels
in: test Issues in the test module status: duplicate A duplicate of another issue type: regression A bug that is also a regression

Comments

@MateuszWicherski
Copy link

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.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Dec 19, 2024
@bclozel bclozel transferred this issue from spring-projects/spring-boot Dec 19, 2024
@sbrannen sbrannen added in: test Issues in the test module status: duplicate A duplicate of another issue type: regression A bug that is also a regression and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Dec 19, 2024
@sbrannen sbrannen self-assigned this Dec 19, 2024
@sbrannen
Copy link
Member

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:

Regards,

Sam

@sbrannen sbrannen closed this as not planned Won't fix, can't repro, duplicate, stale Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: test Issues in the test module status: duplicate A duplicate of another issue type: regression A bug that is also a regression
Projects
None yet
Development

No branches or pull requests

3 participants