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

3.4 @MockBean to @MockitoBean Not Behaving The Same - Cross Post of "Support @MockitoBean on @Configuration classes #33934" #43282

Closed
adase11 opened this issue Nov 25, 2024 · 2 comments
Labels
type: wiki-documentation A documentation update required on the wiki

Comments

@adase11
Copy link

adase11 commented Nov 25, 2024

This is a cross post of spring-projects/spring-framework#33934 - I think it's useful to mention here.

I believe most people will run into this issue for the first time when upgrading to Spring Boot 3.4.

At a high level @MockitoBean is no longer behaving the same as @MockBean was when used in tests.

The examples in spring-projects/spring-framework#33934 as well as my experience are specifically referencing @WebMvcTest (which is from Spring Boot and why I think this should be brought up here).

Shout out to @tobias-lippert for the initial post with a solid example.


Ideally @MockitoBean would be a drop-in replacement for @MockBean and those test-specific configuration classes would continue to work. Alternatively I think it would be useful to document the need to move those @MockitoBean declarations to the test class itself.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 25, 2024
@wilkinsona wilkinsona added type: wiki-documentation A documentation update required on the wiki and removed status: waiting-for-triage An issue we've not yet triaged labels Nov 25, 2024
@wilkinsona
Copy link
Member

I've added a section to the release notes. Beyond that, constructive feedback should be provided in the Spring Framework issue tracker as that's where any changes will be considered and potentially made.

@adase11
Copy link
Author

adase11 commented Nov 25, 2024

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: wiki-documentation A documentation update required on the wiki
Projects
None yet
Development

No branches or pull requests

3 participants