我创建了一个使用WsTestClient
的规范。当我运行测试时(右键单击并选择run ScalaTest in test
中的IntelliJ
),我收到以下错误 - Connection refused: no further information: localhost/0:0:0:0:0:0:0:1:9190
。我做错了什么?
我的测试用例是
class UserControllerSpec extends AsyncWordSpec {
implicit val port:play.api.test.WsTestClient.Port = 9190;
"User signup request with non-JSON body" must {
"return 400 (Bad Request) and the validation text 'Incorrect body type. Body type must be JSON'" in {
val request = WsTestClient.wsUrl("/ws/users/signup")
val responseFuture = request.get()
println("sending dummy signup up request")
responseFuture.map(response =>{
println("response :"+response);
assert(response.status == play.api.http.Status.BAD_REQUEST)
})
}
}
}
对我来说,问题似乎是没有服务器来响应这个客户端。但我假设Play
将自己启动一些服务器。