jeudi 6 octobre 2016

How to use WithApplication in Play Framework Scala Spec2 Testing?

I'm trying to understand how to call my controller and test a route. Maybe I should be using WithServer? I don't know what WithApplication gives me, in fact I can't even find the docs where it tells me what it gives me to use so I can call my controller and test the /status path of my server:

object MySpec extends PlaySpecification with Results {

  "Example Page#index" should {
    "should be valid" in new WithApplication {

      val request = FakeRequest("/status") ????

      val result = call(request) ?????

      status(result) mustEqual OK
      contentAsString(result) must contain("Online")
    }
  }

Should I be using WithServer or am I missing something obvious? Thanks

Aucun commentaire:

Enregistrer un commentaire