Document @⁠SpringExtensionConfig in the reference manual

This commit also updates the Javadoc for the SpringExtension and
@⁠SpringExtensionConfig to point out that the SpringExtension always
uses a test-class scoped ExtensionContext if
@⁠TestInstance(Lifecycle.PER_CLASS) semantics are in effect.

Closes gh-36240
This commit is contained in:
Sam Brannen
2026-01-31 16:24:29 +01:00
parent 6fd84e4c2f
commit a08a4d6068
4 changed files with 64 additions and 1 deletions
@@ -88,7 +88,12 @@ import org.springframework.util.ReflectionUtils.MethodFilter;
* be configured to use a test-class scoped extension context by annotating a
* top-level test class with
* {@link SpringExtensionConfig#useTestClassScopedExtensionContext()
* @SpringExtensionConfig(useTestClassScopedExtensionContext = true)}.
* @SpringExtensionConfig(useTestClassScopedExtensionContext = true)}. Note,
* however, that the {@code SpringExtension} will always use a test-class scoped
* {@code ExtensionContext} if your top-level test class is configured to use JUnit
* Jupiters {@code @TestInstance(Lifecycle.PER_CLASS)} semantics, in which case
* there is no need to declare
* {@code @SpringExtensionConfig(useTestClassScopedExtensionContext = true)}.
*
* <p><strong>NOTE:</strong> This class requires JUnit Jupiter 6.0 or higher.
*
@@ -60,6 +60,11 @@ public @interface SpringExtensionConfig {
* {@code ExtensionContext}. Thus, there is no need to declare this annotation
* attribute with a value of {@code false}.
*
* <p>Similarly, if your top-level test class is configured to use JUnit Jupiters
* {@code @TestInstance(Lifecycle.PER_CLASS)} semantics, the {@code SpringExtension}
* will always use a test-class scoped {@code ExtensionContext}, and there is no need
* to declare {@code @SpringExtensionConfig(useTestClassScopedExtensionContext = true)}.
*
* @see SpringExtension
* @see SpringExtension#getTestInstantiationExtensionContextScope(org.junit.jupiter.api.extension.ExtensionContext)
*/