问题
An Action[T]
means that it accepts a request with body of type T
.
Eg
def getQuestion:Action[JsValue] = silhouette.UserAwareAction.async(parse.json){...}
How do I test the above Action with a request which doesn't contain any body? In my unit test, I call the above action like the following
val request = FakeRequest("POST","ws/questions/get-question")
val responseFuture:Future[Result] = questionsTestEnv.questionsController.getQuestion(request)
But I get error
Error:(182, 92) type mismatch;
found : play.api.test.FakeRequest[play.api.mvc.AnyContentAsEmpty.type]
required: play.api.mvc.Request[play.api.libs.json.JsValue]
val responseFuture:Future[Result] = questionsTestEnv.questionsController.getQuestion(request)
来源:https://stackoverflow.com/questions/55857052/how-to-test-an-actiont-without-a-message-body-in-play-framework