When upgrading to Spring Boot 3.2.1, integration tests break when the @EnableAutoConfiguration annotation is placed on a parent test class.

For example, previously, we could do this:

@EnableAutoConfiguration
@SpringBootTest
@ActiveProfiles("test")
...
public class AbstractIntegrationTest {
   // other stuff if required
}

and then test classes which extend from it work fine:

public class MySpecificTest extends AbstractIntegrationTest {
    // Tests here
}

However since upgrading from Spring Boot 3.1.x or 3.2.0, this now fails, unless @EnableAutoConfiguration is explicitly added to MySpecificTest.

When debugging, it seems like now the behaviour has changed, and this means that now AutoConfigurationImportSelector is also picking up MySpecificTest (whereas before it was only checking AbstractIntegrationTest) for processing, then this line is now failing:

Assert.notNull(attributes, () -> "No auto-configuration attributes found. Is " + metadata.getClassName()
                + " annotated with " + ClassUtils.getShortName(name) + "?");

Having to add @EnableAutoConfiguration to every test class is painful and ugly when the whole point of a parent test class is to provide the full configuration & everything required to actually run the test.

If we do now check the instance classes, if we don't have the @EnableAutoConfiguration method we should check the parent class too, rather than simply asserting not null.

Comment From: wilkinsona

I can't reproduce the behavior that you've described with Spring Boot 3.2.1 when inheriting @EnableAutoConfiguration on a test class. I've tried both with the main application class annotated with @SpringBootApplication and with just @SpringBootConfiguration. If you would like us to spend some more time investigating, please spend some time providing a complete yet minimal sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue.

I'd also quite like to understand why you're using @EnableAutoConfiguration on a test class. It's unusual to only enable auto-configuration in tests and not through the application's main class.

Comment From: jamfor352

Thanks @wilkinsona . Went back and realised this was actually due to a misconfiguration in the first place, so closing this issue.

Comment From: wilkinsona

Thanks for letting us know.

Comment From: GeneralNitin

Thanks @wilkinsona . Went back and realised this was actually due to a misconfiguration in the first place, so closing this issue.

Can you please elaborate what was the misconfiguration. Even I am facing the same issue, all of a sudden after the version upgrade the tests have started failing.