File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed
framework-docs/modules/ROOT/pages/testing/annotations/integration-spring
spring-test/src/main/java/org/springframework/test/context/bean/override/mockito Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -102,6 +102,10 @@ will be replaced with a singleton mock of the type of object created by the `Fac
102102
103103Similarly, when using `@MockitoSpyBean` to create a spy for a `FactoryBean`, a spy will
104104be created for the object created by the `FactoryBean`, not for the `FactoryBean` itself.
105+
106+ Furthermore, `@MockitoSpyBean` cannot be used to spy on a scoped proxy — for example, a
107+ bean annotated with `@Scope(proxyMode = ScopedProxyMode.TARGET_CLASS)`. Any attempt to do
108+ so will fail with an exception.
105109====
106110
107111[NOTE]
Original file line number Diff line number Diff line change 9494 * be created for the object created by the {@code FactoryBean}, not for the
9595 * {@code FactoryBean} itself.
9696 *
97+ * <p><strong>WARNING</strong>: {@code @MockitoSpyBean} cannot be used to spy on
98+ * a scoped proxy — for example, a bean annotated with
99+ * {@link org.springframework.context.annotation.Scope
100+ * @Scope(proxyMode = ScopedProxyMode.TARGET_CLASS)}. Any attempt to do so will
101+ * fail with an exception.
102+ *
97103 * <p>There are no restrictions on the visibility of a {@code @MockitoSpyBean} field.
98104 * Such fields can therefore be {@code public}, {@code protected}, package-private
99105 * (default visibility), or {@code private} depending on the needs or coding
You can’t perform that action at this time.
0 commit comments