diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootTestContextBootstrapper.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootTestContextBootstrapper.java index 26f291e719d9..dda859f0eb6d 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootTestContextBootstrapper.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootTestContextBootstrapper.java @@ -244,8 +244,6 @@ protected Class[] getOrFindConfigurationClasses(MergedContextConfiguration me return classes; } Class found = findConfigurationClass(mergedConfig.getTestClass()); - Assert.state(found != null, "Unable to find a @SpringBootConfiguration, you need to use " - + "@ContextConfiguration or @SpringBootTest(classes=...) with your test"); logger.info("Found @SpringBootConfiguration " + found.getName() + " for test " + mergedConfig.getTestClass()); return merge(found, classes); } @@ -258,6 +256,8 @@ private Class findConfigurationClass(Class testClass) { return ClassUtils.resolveClassName(foundClassName, testClass.getClassLoader()); } Class found = new AnnotatedClassFinder(SpringBootConfiguration.class).findFromClass(testClass); + Assert.state(found != null, "Unable to find a @SpringBootConfiguration, you need to use " + + "@ContextConfiguration or @SpringBootTest(classes=...) with your test"); this.aotTestAttributes.setAttribute(propertyName, found.getName()); return found; }