Description
Overview
Due to the deprecation of @MockBean
and @SpyBean
in favor of Spring Framework's new @MockitoBean
and @MockitoSpyBean
support, several users have raised issues in the Spring Framework issue tracker regarding incompatibilities between the two sets of annotations.
Although incompatibilities are to be expected, it is not immediately clear to users what the differences are.
To address that, the Framework team proposes that the Boot team introduce a new section in the Mocking and Spying Beans section of the reference docs that lists known differences and potential migration strategies.
This could perhaps be addressed via a "compatibility matrix" for the 4 annotations.
Since the deprecation of @MockBean
and @SpyBean
and the migration to @MockitoBean
and @MockitoSpyBean
are specific to Boot, the Framework team feels the migration/compatibility documentation would best reside in Boot's reference docs.
Ideally, members of the Boot and Framework teams could collaborate on compiling the compatibility matrix, and I'd be happy to assist with that.
Related Issues
- 3.4 @MockBean to @MockitoBean Not Behaving The Same - Cross Post of "Support @MockitoBean on @Configuration classes #33934" #43282
- Support
@MockitoBean
at the type level on test classes spring-framework#33925 - Support
@MockitoBean
in@Configuration
classes spring-framework#33934 @MockitoSpyBean
requires existing bean instance to spy on spring-framework#33935- etc.