【发布时间】:2017-09-03 00:43:15
【问题描述】:
我有一个 JUnit 测试,它在测试后启动一个 spring-boot 应用程序(在我的例子中,主类是 SpringTestDemoApp):
@WebIntegrationTest
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = SpringTestDemoApp.class)
public class SpringTest {
@Test
public void test() {
// Test http://localhost:8080/ (with Selenium)
}
}
使用 spring-boot 1.3.3.RELEASE 一切正常。尽管如此,注释 @WebIntegrationTest 和 @SpringApplicationConfiguration 已在 spring-boot 1.5.2.RELEASE 中删除。我试图将代码重构为新版本,但我无法做到。通过以下测试,我的应用在测试之前没有启动,http://localhost:8080 返回 404:
@RunWith(SpringRunner.class)
@SpringBootTest(classes = SpringTestDemoApp.class)
@WebAppConfiguration
public class SpringTest {
@Test
public void test() {
// The same test than before
}
}
如何重构我的测试以使其在 spring-boot 1.5 中工作?
【问题讨论】:
-
您能在日志中看到任何异常/消息吗?
标签: java spring spring-boot junit spring-test