|
29 | 29 | * Mark a field to override a bean definition in the {@code BeanFactory}.
|
30 | 30 | *
|
31 | 31 | * <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 |
33 | 33 | * 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. |
36 | 38 | *
|
37 | 39 | * <p>The instance is created from a zero-argument static factory method in the
|
38 | 40 | * 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. |
40 | 42 | * 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 |
42 | 44 | * follows.
|
| 45 | + * |
43 | 46 | * <ul>
|
44 | 47 | * <li>If the {@link #methodName()} is specified, look for a static method with
|
45 | 48 | * that name.</li>
|
|
109 | 112 | /**
|
110 | 113 | * Name of the bean to override.
|
111 | 114 | * <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. |
113 | 117 | * @see #value()
|
114 | 118 | */
|
115 | 119 | @AliasFor("value")
|
116 | 120 | String name() default "";
|
117 | 121 |
|
118 | 122 | /**
|
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. |
124 | 128 | * <p>If left unspecified, the name of the factory method will be detected
|
125 | 129 | * based either on the name of the annotated field or the name of the bean.
|
126 | 130 | */
|
|
0 commit comments