Document that TestContextAnnotationUtils is required for @Nested support
Closes gh-33586
This commit is contained in:
parent
f7aa4409bb
commit
6a9b5d21f4
|
@ -542,6 +542,14 @@ any of its subclasses and nested classes. Thus, you may annotate a top-level tes
|
||||||
with `@NestedTestConfiguration`, and that will apply to all of its nested test classes
|
with `@NestedTestConfiguration`, and that will apply to all of its nested test classes
|
||||||
recursively.
|
recursively.
|
||||||
|
|
||||||
|
[TIP]
|
||||||
|
====
|
||||||
|
If you are developing a component that integrates with the Spring TestContext Framework
|
||||||
|
and needs to support annotation inheritance within enclosing class hierarchies, you must
|
||||||
|
use the annotation search utilities provided in `TestContextAnnotationUtils` in order to
|
||||||
|
honor `@NestedTestConfiguration` semantics.
|
||||||
|
====
|
||||||
|
|
||||||
In order to allow development teams to change the default to `OVERRIDE` – for example,
|
In order to allow development teams to change the default to `OVERRIDE` – for example,
|
||||||
for compatibility with Spring Framework 5.0 through 5.2 – the default mode can be changed
|
for compatibility with Spring Framework 5.0 through 5.2 – the default mode can be changed
|
||||||
globally via a JVM system property or a `spring.properties` file in the root of the
|
globally via a JVM system property or a `spring.properties` file in the root of the
|
||||||
|
|
|
@ -58,10 +58,16 @@ import org.springframework.lang.Nullable;
|
||||||
* <p>This annotation may be used as a <em>meta-annotation</em> to create custom
|
* <p>This annotation may be used as a <em>meta-annotation</em> to create custom
|
||||||
* <em>composed annotations</em>.
|
* <em>composed annotations</em>.
|
||||||
*
|
*
|
||||||
* <p>As of Spring Framework 5.3, the use of this annotation typically only makes
|
* <p>The use of this annotation typically only makes sense in conjunction with
|
||||||
* sense in conjunction with {@link org.junit.jupiter.api.Nested @Nested} test
|
* {@link org.junit.jupiter.api.Nested @Nested} test classes in JUnit Jupiter;
|
||||||
* classes in JUnit Jupiter; however, there may be other testing frameworks with
|
* however, there may be other testing frameworks with support for nested test
|
||||||
* support for nested test classes that could also make use of this annotation.
|
* classes that could also make use of this annotation.
|
||||||
|
*
|
||||||
|
* <p>If you are developing a component that integrates with the Spring TestContext
|
||||||
|
* Framework and needs to support annotation inheritance within enclosing class
|
||||||
|
* hierarchies, you must use the annotation search utilities provided in
|
||||||
|
* {@link TestContextAnnotationUtils} in order to honor
|
||||||
|
* {@code @NestedTestConfiguration} semantics.
|
||||||
*
|
*
|
||||||
* <h3>Supported Annotations</h3>
|
* <h3>Supported Annotations</h3>
|
||||||
* <p>The <em>Spring TestContext Framework</em> honors {@code @NestedTestConfiguration}
|
* <p>The <em>Spring TestContext Framework</em> honors {@code @NestedTestConfiguration}
|
||||||
|
@ -89,6 +95,7 @@ import org.springframework.lang.Nullable;
|
||||||
* @since 5.3
|
* @since 5.3
|
||||||
* @see EnclosingConfiguration#INHERIT
|
* @see EnclosingConfiguration#INHERIT
|
||||||
* @see EnclosingConfiguration#OVERRIDE
|
* @see EnclosingConfiguration#OVERRIDE
|
||||||
|
* @see TestContextAnnotationUtils
|
||||||
*/
|
*/
|
||||||
@Target(ElementType.TYPE)
|
@Target(ElementType.TYPE)
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2023 the original author or authors.
|
* Copyright 2002-2024 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -47,7 +47,8 @@ import org.springframework.util.ObjectUtils;
|
||||||
* and {@link AnnotatedElementUtils}, while transparently honoring
|
* and {@link AnnotatedElementUtils}, while transparently honoring
|
||||||
* {@link NestedTestConfiguration @NestedTestConfiguration} semantics.
|
* {@link NestedTestConfiguration @NestedTestConfiguration} semantics.
|
||||||
*
|
*
|
||||||
* <p>Mainly for internal use within the <em>Spring TestContext Framework</em>.
|
* <p>Mainly for internal use within the <em>Spring TestContext Framework</em>
|
||||||
|
* but also supported for third-party integrations with the TestContext framework.
|
||||||
*
|
*
|
||||||
* <p>Whereas {@code AnnotationUtils} and {@code AnnotatedElementUtils} provide
|
* <p>Whereas {@code AnnotationUtils} and {@code AnnotatedElementUtils} provide
|
||||||
* utilities for <em>getting</em> or <em>finding</em> annotations,
|
* utilities for <em>getting</em> or <em>finding</em> annotations,
|
||||||
|
@ -70,6 +71,7 @@ import org.springframework.util.ObjectUtils;
|
||||||
* @see AnnotationUtils
|
* @see AnnotationUtils
|
||||||
* @see AnnotatedElementUtils
|
* @see AnnotatedElementUtils
|
||||||
* @see AnnotationDescriptor
|
* @see AnnotationDescriptor
|
||||||
|
* @see NestedTestConfiguration
|
||||||
*/
|
*/
|
||||||
public abstract class TestContextAnnotationUtils {
|
public abstract class TestContextAnnotationUtils {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue