Skip to content

Commit

Permalink
Avoid NPE when @SpringBootConfiguration not found in test
Browse files Browse the repository at this point in the history
  • Loading branch information
lishangbu authored and mhalbritter committed Dec 1, 2022
1 parent 93f8dc7 commit f5d0171
Showing 1 changed file with 2 additions and 2 deletions.
Expand Up @@ -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);
}
Expand All @@ -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;
}
Expand Down

0 comments on commit f5d0171

Please sign in to comment.