mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-17 08:24:13 +00:00
Merge branch '7.0.x'
This commit is contained in:
+12
@@ -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 — for example, due to {@code @Transactional}, {@code @Cacheable}, or
|
||||
* {@code @Retryable} — 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
|
||||
|
||||
Reference in New Issue
Block a user