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?