Skip to content

Commit 1954861

Browse files
committed
Update @TestPropertySource Javadoc regarding "local" semantics
See gh-23320
1 parent 690694d commit 1954861

File tree

1 file changed

+36
-5
lines changed

1 file changed

+36
-5
lines changed

spring-test/src/main/java/org/springframework/test/context/TestPropertySource.java

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,24 @@
172172
* @ContextConfiguration
173173
* public class ExtendedTest extends BaseTest {
174174
* // ...
175-
* }
176-
* </pre>
177-
*
175+
* }</pre>
176+
* <p>If {@code @TestPropertySource} is used as a <em>{@linkplain Repeatable
177+
* repeatable}</em> annotation, the following special rules apply.
178+
* <ol>
179+
* <li>All {@code @TestPropertySource} annotations at a given level in the
180+
* test class hierarchy (i.e., directly present or meta-present on a test
181+
* class) are considered to be <em>local</em> annotations, in contrast to
182+
* {@code @TestPropertySource} annotations that are inherited from a
183+
* superclass.</li>
184+
* <li>All local {@code @TestPropertySource} annotations must declare the
185+
* same value for the {@code inheritLocations} flag.</li>
186+
* <li>The {@code inheritLocations} flag is not taken into account between
187+
* local {@code @TestPropertySource} annotations. Specifically, the property
188+
* source locations for one local annotation will be appended to the list of
189+
* property source locations defined by previous local annotations. This
190+
* allows a local annotation to extend the list of test property source
191+
* locations, potentially overriding individual properties.</li>
192+
* </ol>
178193
* @see #locations
179194
*/
180195
boolean inheritLocations() default true;
@@ -232,8 +247,24 @@
232247
* &#064;ContextConfiguration
233248
* public class ExtendedTest extends BaseTest {
234249
* // ...
235-
* }
236-
* </pre>
250+
* }</pre>
251+
* <p>If {@code @TestPropertySource} is used as a <em>{@linkplain Repeatable
252+
* repeatable}</em> annotation, the following special rules apply.
253+
* <ol>
254+
* <li>All {@code @TestPropertySource} annotations at a given level in the
255+
* test class hierarchy (i.e., directly present or meta-present on a test
256+
* class) are considered to be <em>local</em> annotations, in contrast to
257+
* {@code @TestPropertySource} annotations that are inherited from a
258+
* superclass.</li>
259+
* <li>All local {@code @TestPropertySource} annotations must declare the
260+
* same value for the {@code inheritProperties} flag.</li>
261+
* <li>The {@code inheritProperties} flag is not taken into account between
262+
* local {@code @TestPropertySource} annotations. Specifically, inlined
263+
* properties for one local annotation will be appended to the list of
264+
* inlined properties defined by previous local annotations. This allows a
265+
* local annotation to extend the list of inlined properties, potentially
266+
* overriding individual properties.</li>
267+
* </ol>
237268
* @see #properties
238269
*/
239270
boolean inheritProperties() default true;

0 commit comments

Comments
 (0)