When we try spring boot test without @SpringBootConfiguration,NPE exception will occur. Before supporting AOT,it throws IllegalStateException with message:

Unable to find a @SpringBootConfiguration, you need to use "
                + "@ContextConfiguration or @SpringBootTest(classes=...) with your test

but now it occurs exception like this:

java.lang.NullPointerException: Cannot invoke "java.lang.Class.getName()" because "found" is null

    at org.springframework.boot.test.context.SpringBootTestContextBootstrapper.findConfigurationClass(SpringBootTestContextBootstrapper.java:261)

I find that class is not checking null before setting aotTestAttributes :

Class<?> found = new AnnotatedClassFinder(SpringBootConfiguration.class).findFromClass(testClass);
this.aotTestAttributes.setAttribute(propertyName, found.getName());

We can avoid this with a small change by checking whether class with @SpringBootConfiguration is null in advance.We can move checking code from getOrFindConfigurationClasses to findConfigurationClass before setting aotTestAttributes

Comment From: wilkinsona

Closing in favor of #33371. Thanks for the PR, @lishangbu.