Browse Source
Prior to this commit, if a superclass or enclosing test class (such as one annotated with @SpringBootTest or simply @ExtendWith(SpringExtension.class)) was not annotated with @ContextConfiguration (or @Import with @SpringBootTest), the ApplicationContext loaded for a subclass or @Nested test class would not use any default context configuration for the superclass or enclosing test class. Effectively, a default XML configuration file or static nested @Configuration class for the superclass or enclosing test class was not discovered by the AbstractTestContextBootstrapper when attempting to build the MergedContextConfiguration (application context cache key). To address that, this commit introduces a new resolveDefaultContextConfigurationAttributes() method in ContextLoaderUtils which is responsible for creating instances of ContextConfigurationAttributes for all superclasses and enclosing classes. This effectively enables AbstractTestContextBootstrapper to delegate to the resolved SmartContextLoader to properly detect a default XML configuration file or static nested @Configuration class even if such classes are not annotated with @ContextConfiguration. Closes gh-31456pull/36467/head
4 changed files with 4 additions and 66 deletions
Loading…
Reference in new issue