-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Description
Overview
As of Spring Framework 6.2.13 (see #35680), we support JUnit Jupiter's ExtensionContextScope.TEST_METHOD behavior in the SpringExtension and the BeanOverrideTestExecutionListener; however, users can only benefit from that if they explicitly set the junit.jupiter.extensions.testinstantiation.extensioncontextscope.default configuration parameter to test_method for their entire test suite, which may have adverse effects on third-party JUnit Jupiter extensions.
For Spring Framework 7.0, in order to support common @Autowired injection scenarios in @Nested test class hierarchies by default, we should configure the SpringExtension to use ExtensionContextScope.TEST_METHOD, and we should provide a mechanism for users to switch back to the legacy "test-class scoped ExtensionContext" behavior — for example, via a type-level annotation that can be applied to a given @Nested test class hierarchy.
Related Issues
- Provide guidance on using
@Nestedwithin test classes with complex inheritance and annotation arrangements #28466 - No transaction in progress for
@Nestedtest class #34576 - Introduce
isAutowirableConstructor(Executable, PropertyProvider)inTestConstructorUtilsand deprecate existing variants #35676 - JUnit Jupiter
TEST_METHODExtensionContextScopeis not fully supported #35680 - Document test-method scoped
TestContextsemantics #35716 - Optionally provide test-scoped
ExtensionContextfor test-specific callbacks in extensions junit-team/junit-framework#3445 - Replace opt-in annotation with extension method junit-team/junit-framework#4062
- Introduce configuration parameter for default extension context scope junit-team/junit-framework#4064
- Improve documentation for
TestInstantiationAwareExtensionand raise awareness of semantic differences junit-team/junit-framework#5107