You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While upgrading our apps to Spring Boot 3.4.0, I've encountered that some of our tests don't start because the application context cannot be created due to a missing bean dependency that should exist as mocked bean.
We define some mocks in a config class annotated with @TestConfiguration and import this class using @Import.
When I define a MockBean, the tests succeed.
I couldn't find anything in the docs pointing out that this should no longer work. If this is not a bug, but intended behavior please advise how to fix this.
The easiest, but not the prettiest workaround I've found is getting rid of the separate TestConfigurations and placing all MockitoBeans in the actual test class.
The text was updated successfully, but these errors were encountered:
Versions
Spring Boot 3.4.0
Spring Framework 6.2.0
Hi Spring team,
While upgrading our apps to Spring Boot 3.4.0, I've encountered that some of our tests don't start because the application context cannot be created due to a missing bean dependency that should exist as mocked bean.
We define some mocks in a config class annotated with
@TestConfiguration
and import this class using@Import
.When I define a MockBean, the tests succeed.
You can find an example that reproduces the behavior here: https://github.com/tobias-lippert/spring-mockitobean-test-configuration-import-bug
The test passes on the branch mockbean-working and fails on the branch mockitobean-not-working.
I couldn't find anything in the docs pointing out that this should no longer work. If this is not a bug, but intended behavior please advise how to fix this.
The easiest, but not the prettiest workaround I've found is getting rid of the separate
TestConfigurations
and placing allMockitoBeans
in the actual test class.The text was updated successfully, but these errors were encountered: