Skip to content

Commit c2f8d48

Browse files
committed
Update Javadoc for @⁠TestBean
1 parent b105fdc commit c2f8d48

File tree

1 file changed

+15
-11
lines changed
  • spring-test/src/main/java/org/springframework/test/context/bean/override/convention

1 file changed

+15
-11
lines changed

spring-test/src/main/java/org/springframework/test/context/bean/override/convention/TestBean.java

+15-11
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,20 @@
2929
* Mark a field to override a bean definition in the {@code BeanFactory}.
3030
*
3131
* <p>By default, the bean to override is inferred from the type of the
32-
* annotated field. This requires that exactly one matching definition is
32+
* annotated field. This requires that exactly one matching bean definition is
3333
* present in the application context. A {@code @Qualifier} annotation can be
34-
* used to help disambiguate. Alternatively, you can explicitly specify a bean
35-
* name to replace by setting the {@link #value()} or {@link #name()} attribute.
34+
* used to help disambiguate. In the absence of a {@code @Qualifier} annotation,
35+
* the name of the annotated field will be used as a qualifier. Alternatively,
36+
* you can explicitly specify a bean name to replace by setting the
37+
* {@link #value()} or {@link #name()} attribute.
3638
*
3739
* <p>The instance is created from a zero-argument static factory method in the
3840
* test class whose return type is compatible with the annotated field. In the
39-
* case of a nested test class, the enclosing class hierarchy is also considered.
41+
* case of a nested test class, the enclosing class hierarchy is also searched.
4042
* Similarly, if the test class extends from a base class or implements any
41-
* interfaces, the entire type hierarchy is considered. The method is deduced as
43+
* interfaces, the entire type hierarchy is searched. The method is deduced as
4244
* follows.
45+
*
4346
* <ul>
4447
* <li>If the {@link #methodName()} is specified, look for a static method with
4548
* that name.</li>
@@ -109,18 +112,19 @@
109112
/**
110113
* Name of the bean to override.
111114
* <p>If left unspecified, the bean to override is selected according to
112-
* the annotated field's type.
115+
* the annotated field's type, taking qualifiers into account if necessary.
116+
* See the {@linkplain TestBean class-level documentation} for details.
113117
* @see #value()
114118
*/
115119
@AliasFor("value")
116120
String name() default "";
117121

118122
/**
119-
* Name of a static factory method to look for in the test class, which will
120-
* be used to instantiate the bean to override.
121-
* <p>In the case of a nested test, any enclosing class it might have is
122-
* also considered. Similarly, in case the test class inherits from a base
123-
* class the whole class hierarchy is considered.
123+
* Name of the static factory method that will be used to instantiate the bean
124+
* to override.
125+
* <p>A search will be performed to find the factory method in the test class,
126+
* in one of its superclasses, or in any implemented interfaces. In the case
127+
* of a nested test class, the enclosing class hierarchy will also be searched.
124128
* <p>If left unspecified, the name of the factory method will be detected
125129
* based either on the name of the annotated field or the name of the bean.
126130
*/

0 commit comments

Comments
 (0)