Unable to run a POST test in play framework

2019-09-12 16:32发布

问题:

I am trying to run a quick scalatest for a POST call

the following does not seem to hit my controller

  test("testpost") {
    val r = routeAndCall(FakeRequest(POST, "/2/testpost")) 
  }

if I change the routes and make it a GET and change the test to ... FakeRequest(GET, .... then it hits the controller. What am I doing wrong here?

Here is the controller code in question:

def testpost = Action { implicit request =>
    logger.info("inside testpost")
    Ok
}

And my routes file has this line:

POST        /2/testpost             controllers.AccountCtrlr.testpost()

I never see the log print, if i change everything to GET it seems to work fine.

Thanks