mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
d8a6423c0c
Prior to this commit, SpringAopBypassingVerificationStartedListener provided partial support for transparent verification for Mockito spies created via @MockitoSpyBean when the spy is wrapped in a Spring AOP proxy. However, attempting to actually verify invocations for a spy resulted in an exception from Mockito since MockUtil.isMock() returned false in such scenarios. This commit addresses that by introducing a SpringMockResolver that resolves mocks by walking the Spring AOP proxy chain until the target or a non-static proxy is found. SpringMockResolver is automatically registered whenever the spring-test JAR is on the classpath, allowing Mockito to transparently resolve mocks wrapped in Spring AOP proxies. Closes gh-33774