@@ -5,6 +5,7 @@ The following annotations are supported when used in conjunction with the
55xref:testing/testcontext-framework/support-classes.adoc#testcontext-junit-jupiter-extension[`SpringExtension`]
66and JUnit Jupiter (that is, the programming model in JUnit):
77
8+ * xref:testing/annotations/integration-junit-jupiter.adoc#integration-testing-annotations-springextensionconfig[`@SpringExtensionConfig`]
89* xref:testing/annotations/integration-junit-jupiter.adoc#integration-testing-annotations-junit-jupiter-springjunitconfig[`@SpringJUnitConfig`]
910* xref:testing/annotations/integration-junit-jupiter.adoc#integration-testing-annotations-junit-jupiter-springjunitwebconfig[`@SpringJUnitWebConfig`]
1011* xref:testing/annotations/integration-junit-jupiter.adoc#integration-testing-annotations-testconstructor[`@TestConstructor`]
@@ -14,6 +15,47 @@ and JUnit Jupiter (that is, the programming model in JUnit):
1415* xref:testing/annotations/integration-spring/annotation-disabledinaotmode.adoc[`@DisabledInAotMode`]
1516
1617
18+ [[integration-testing-annotations-springextensionconfig]]
19+ == `@SpringExtensionConfig`
20+
21+ `@SpringExtensionConfig` is a type-level annotation that can be used to configure the
22+ behavior of the `SpringExtension`.
23+
24+ As of Spring Framework 7.0, the `SpringExtension` is configured to use a test-method
25+ scoped `ExtensionContext`, which enables consistent dependency injection into fields and
26+ constructors from the `ApplicationContext` for the current test method in a `@Nested`
27+ test class hierarchy. However, if a third-party `TestExecutionListener` is not compatible
28+ with the semantics associated with a test-method scoped extension context — or if a
29+ developer wishes to switch to test-class scoped semantics — the `SpringExtension` can be
30+ configured to use a test-class scoped `ExtensionContext` by annotating a top-level test
31+ class with `@SpringExtensionConfig(useTestClassScopedExtensionContext = true)`.
32+
33+ [TIP]
34+ ====
35+ If your top-level test class is configured to use JUnit Jupiter's
36+ `@TestInstance(Lifecycle.PER_CLASS)` semantics, the `SpringExtension` will always use a
37+ test-class scoped `ExtensionContext`, and there is no need to declare
38+ `@SpringExtensionConfig(useTestClassScopedExtensionContext = true)`.
39+ ====
40+
41+ [NOTE]
42+ ====
43+ This annotation is currently only applicable to `@Nested` test class hierarchies and
44+ should be applied to the top-level enclosing class of a `@Nested` test class hierarchy.
45+
46+ Consequently, there is no need to declare this annotation on a test class that does not
47+ contain `@Nested` test classes.
48+ ====
49+
50+ [NOTE]
51+ ====
52+ xref:testing/annotations/integration-junit-jupiter.adoc#integration-testing-annotations-nestedtestconfiguration[`@NestedTestConfiguration`]
53+ does not apply to this annotation.
54+
55+ `@SpringExtensionConfig` will always be detected within a `@Nested` test class hierarchy,
56+ effectively disregarding any `@NestedTestConfiguration(OVERRIDE)` declarations.
57+ ====
58+
1759[[integration-testing-annotations-junit-jupiter-springjunitconfig]]
1860== `@SpringJUnitConfig`
1961
0 commit comments