简体   繁体   中英

Spring Boot integration test can't find configuration

I have a simple Spring Boot application, consisting only of this class:

@SpringBootApplication
public class TestApplication {

    public static void main(String[] args) {
        SpringApplication.run(TestApplication.class, args);
    }
}

I want to test whether the application starts. That test looks like this:

@SpringBootTest
public class UserServiceIT {

    @Test
    public void testContextLoads() {
        assertTrue(true);
    }

}

When I run this test from my IDE (IntelliJ), it passes. This is the expected behavior.

When I run it from the command line ( mvn integration-test ), I get the following failure:

java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=...) with your test

I'm using the following versions:

  • Java: 14
  • Maven: 3.6.0
  • spring-boot: 2.3.4.RELEASE
  • junit-jupiter: 5.6.2 (I'm not using JUnit 4)
  • maven-failsafe-plugin: 3.0.0.M5

Any ideas as to why this fails on the command line?

I tried rolling back the version of maven-failsafe-plugin to 3.0.0.M4 and the test passed from the command line. Therefore this appears to be a bug in 3.0.0.M5 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM