Action[T]
表示它接受类型为T
的请求。
例如
def getQuestion:Action[JsValue] = silhouette.UserAwareAction.async(parse.json){...}
如何使用不包含任何正文的请求测试上述Action?在我的单元测试中,我将上述操作称为如下
val request = FakeRequest("POST","ws/questions/get-question")
val responseFuture:Future[Result] = questionsTestEnv.questionsController.getQuestion(request)
但是我得到了错误
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)