Support detection and with test initializers

Relax `SpringBootTestContextBootstrapper` rules so that a test can
specify an `ApplicationContextInitializer` and still have
`@SpringBootConfiguration` detected.

Prior to this commit detection would not occur because it's possible
that an initializer _could_ register configuration. This scenario is
actually quite unlikely to occur, certainly less likely than wanting to
use an initializer in combination with auto-detection.

Fixes gh-8483
This commit is contained in:
Phillip Webb
2017-04-19 17:15:59 -07:00
parent c9561f031c
commit 5abc050a96
3 changed files with 71 additions and 2 deletions

View File

@@ -194,8 +194,7 @@ public class SpringBootTestContextBootstrapper extends DefaultTestContextBootstr
protected Class<?>[] getOrFindConfigurationClasses(
MergedContextConfiguration mergedConfig) {
Class<?>[] classes = mergedConfig.getClasses();
if (containsNonTestComponent(classes) || mergedConfig.hasLocations()
|| !mergedConfig.getContextInitializerClasses().isEmpty()) {
if (containsNonTestComponent(classes) || mergedConfig.hasLocations()) {
return classes;
}
Class<?> found = new SpringBootConfigurationFinder()