我有一个简单的Spring Boot应用程序,仅包含此类:
@SpringBootApplication
public class TestApplication {
public static void main(String[] args) {
SpringApplication.run(TestApplication.class, args);
}
}
我想测试应用程序是否启动。该测试如下所示:
@SpringBootTest
public class UserServiceIT {
@Test
public void testContextLoads() {
assertTrue(true);
}
}
当我从IDE(IntelliJ)运行此测试时,它通过了。这是预期的行为。
当我从命令行(mvn integration-test
)运行它时,出现以下错误:
java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=...) with your test
我正在使用以下版本:
关于为什么在命令行上失败的任何想法?
答案 0 :(得分:0)
我尝试将maven-failsafe-plugin
的版本回滚到3.0.0.M4
,并从命令行通过了测试。因此,这似乎是3.0.0.M5
中的错误。