Document that @⁠MockitoSpyBean cannot spy on a scoped proxy

See gh-35722
This commit is contained in:
Sam Brannen
2025-11-04 13:42:22 +01:00
parent c0c94d5d86
commit b019ebee6e
2 changed files with 10 additions and 0 deletions
@@ -94,6 +94,12 @@ import org.springframework.test.context.bean.override.BeanOverride;
* be created for the object created by the {@code FactoryBean}, not for the
* {@code FactoryBean} itself.
*
* <p><strong>WARNING</strong>: {@code @MockitoSpyBean} cannot be used to spy on
* a scoped proxy &mdash; for example, a bean annotated with
* {@link org.springframework.context.annotation.Scope
* &#64;Scope(proxyMode = ScopedProxyMode.TARGET_CLASS)}. Any attempt to do so will
* fail with an exception.
*
* <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