Sam Brannen opened SPR-15366 and commented
Status Quo
Spring's support for JUnit Jupiter already supports detection of test configuration (e.g., (@ContextConfiguration) on @Nested classes.
However, if a @Nested class does not declare its own test configuration, Spring will not find the configuration from the enclosing class.
See also this discussion on Stack Overflow regarding nested test classes and @Transactional.
Proposal
Inspired by issue 8 from the spring-test-junit5 project, it would perhaps be desirable if the Spring TestContext Framework would discover test configuration on an enclosing class for a @Nested test class.
Deliverables
Affects: 5.0
Issue Links:
6 votes, 10 watchers
Sam Brannen opened SPR-15366 and commented
Status Quo
Spring's support for JUnit Jupiter already supports detection of test configuration (e.g., (
@ContextConfiguration) on@Nestedclasses.However, if a
@Nestedclass does not declare its own test configuration, Spring will not find the configuration from the enclosing class.See also this discussion on Stack Overflow regarding nested test classes and
@Transactional.Proposal
Inspired by issue 8 from the
spring-test-junit5project, it would perhaps be desirable if the Spring TestContext Framework would discover test configuration on an enclosing class for a@Nestedtest class.Deliverables
@NestedTestConfigurationwithEnclosingConfigurationenum supportingINHERITEDandOVERRIDEmodes.EnclosingConfigurationmode globally configurable viaSpringPropertiesEnclosingConfigurationmode toINHERITED@ContextConfiguration/@ContextHierarchy@ActiveProfiles@TestPropertySource/@TestPropertySources@WebAppConfiguration@TestConstructor@BootstrapWith@TestExecutionListeners@DirtiesContext@Transactional@Rollback/@Commit@Sql/@SqlConfig/@SqlGroup@NestedTestConfigurationsupport in the reference manual@NestedTestConfigurationsupport and the switching of the default mode toINHERITEDin the upgrade notes in the wikiAffects: 5.0
Issue Links:
@Nestedclass cannot share enclosing class's ApplicationContext if nested class is deemed to be a configuration candidate6 votes, 10 watchers