Overview
SpringAopBypassingVerificationStartedListener
provides partial support for transparent verification for Mockito spies created via @MockitoSpyBean
when the spy is wrapped in a Spring AOP proxy.
However, the following @Disabled
test currently fails since the AOP proxy for the DateService
is not considered a mock by Mockito.
https://github.com/spring-projects/spring-framework/blob/982f7f8f58a6368866559d969b5d4801557af2fd/spring-test/src/test/java/org/springframework/test/context/bean/override/mockito/MockitoSpyBeanAndAopProxyTests.java#L88-L117
To provide transparent verification support for @MockitoSpyBean
, we need to implement and register a Mockito MockResolver
, analogous to the SpringBootMockResolver
in Spring Boot.
Related Issues
- https://github.com/spring-projects/spring-framework/issues/29215#issuecomment-1271620565
- https://github.com/spring-projects/spring-boot/issues/32632
- https://github.com/spring-projects/spring-boot/issues/22416
- https://github.com/mockito/mockito/issues/1980
Comment From: philwebb
This unfortunately breaks code that doesn't have spring-aop
on the classpath.