Skip to content

Failing integration tests after spring upgrade to 2.3.4 with error No auto-configuration found #26407

@nandwaniS

Description

@nandwaniS

Our integration tests started to fail after the upgrade to 2.3.4.

Caused by: java.lang.IllegalArgumentException: No auto-configuration attributes found. Is TestClass annotated with EnableAutoConfiguration?
	at org.springframework.util.Assert.notNull(Assert.java:218)
	at org.springframework.boot.autoconfigure.AutoConfigurationImportSelector.getAttributes(AutoConfigurationImportSelector.java:155)
	at org.springframework.boot.autoconfigure.AutoConfigurationImportSelector.getAutoConfigurationEntry(AutoConfigurationImportSelector.java:122)
	at org.springframework.boot.autoconfigure.AutoConfigurationImportSelector$AutoConfigurationGroup.process(AutoConfigurationImportSelector.java:434)
	at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorGrouping.getImports(ConfigurationClassParser.java:879)
	at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorGroupingHandler.processGroupImports(ConfigurationClassParser.java:809)
	at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorHandler.process(ConfigurationClassParser.java:780)

The setup looks like

@ContextConfiguration(classes = TestConfig.class)
public class IntegrationTest{


}

@Configuration
@ActiveProfiles("test")
@Import({ DummyConfig.class })
public class TestConfig extends MainConfig {


}

After adding the @EnableAutoConfiguration to my integration tests, the test started to pass. However, I did not have to add any annotation in the spring earlier versions.
Also, from the debugging I could see that AutoConfigurationImportSelector is never invoked in 2.0.8 but is invoked in 2.3.4.
Is this what I should expect as a behaviour change in spring upgrade? If not, please let me know the cause of this issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions