Merge branch '7.0.x'

This commit is contained in:
Sam Brannen
2026-08-09 17:47:04 +03:00
5 changed files with 349 additions and 2 deletions
@@ -102,6 +102,18 @@ import org.springframework.test.context.bean.override.BeanOverride;
* @Scope(proxyMode = ScopedProxyMode.TARGET_CLASS)}. Any attempt to do so will
* fail with an exception.
*
* <p><strong>WARNING</strong>: If the original bean would be wrapped in a Spring AOP
* proxy &mdash; for example, due to {@code @Transactional}, {@code @Cacheable}, or
* {@code @Retryable} &mdash; that proxy is still created around the spy, so the bean
* injected into the {@code ApplicationContext} is the proxy rather than the spy.
* Verification via Mockito's {@code verify()} API is unaffected, but stubbing via
* the proxy is only safe for AOP advice that does not retain state between
* invocations; whereas, advice that caches or otherwise memoizes the outcome of an
* invocation can permanently mask the spy's configured answers. See the
* <a href="https://docs.spring.io/spring-framework/reference/testing/annotations/integration-spring/annotation-mockitobean.html#spring-testing-annotation-beanoverriding-mockitospybean-aop-proxies"
* >{@code @MockitoSpyBean} and Spring AOP Proxies</a> section of the Spring Framework
* reference documentation for details.
*
* <p>There are no restrictions on the visibility of a {@code @MockitoSpyBean} field.
* Such fields can therefore be {@code public}, {@code protected}, package-private
* (default visibility), or {@code private} depending on the needs or coding