1

我的测试代码是这样的

@Test
public void testloginController() throws InterruptedException {
    running(testServer(9000), new Runnable() {
        public void run() {
            JsonNode jsonBody = Json.toJson(myObject);
            WSRequestHolder requestBuilder = WS.url("requestURL").setContentType("application/json");

            WSRequestHolder requestHolder = requestBuilder.setTimeout(80000);
            Promise<WS.Response> promiseOfResult = requestHolder.post(jsonBody);
            WS.Response response = promiseOfResult.get();
            JsonNode jsonResponse = response.asJson();
        }
    });
}    

案例 1:如果我使用“play test”命令,那么这段代码运行正常。

案例 2如果我使用“mvn test”,那么我收到以下错误“Bad Request occurred Invalid Json” 但是如果应用程序服务器在测试执行时单独运行,那么它工作正常

4

0 回答 0