我正在使用rest-assured和Spring Boot编写测试。不幸的是,服务没有在测试中开始。这是我的代码:
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = ServiceApplication.class)
@WebAppConfiguration
@IntegrationTest("server.port:8083")
@Slf4j
public class ServicePingIT {
@Value("${local.server.port}")
int port;
private String Uri = "/service/ping";
private String validation = "Service is up and running...";
@Before
public void setup() {
RestAssured.port = port;
RestAssured.baseURI="http://localhost";
}
@Test
public void validatePingBody() {
log.info("");
validateREsponse(Uri, validation);
}
我的测试设置有什么问题,服务没有启动?在日志中我确实看到Tomcat在端口启动但是失败并出现此错误:
ERROR 7432 --- [cat-startStop-1] org.apache.catalina.core.ContainerBase : A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[/service]]
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:188)