Functional testing
Let's look at some of Play's test cases to see how to use the helper methods. For example, consider the DevErrorPageSpec
test, which is defined as follows:
object DevErrorPageSpec extends PlaySpecification{ "devError.scala.html" should { val testExceptionSource = new play.api.PlayException.ExceptionSource("test", "making sure the link shows up") { ... } …. "show prod error page in prod mode" in { val fakeApplication = new FakeApplication() { override val mode = play.api.Mode.Prod } running(fakeApplication) { val result = DefaultGlobal.onError(FakeRequest(), testExceptionSource) Helpers.contentAsString(result) must contain("Oops, an error occurred") } } } }
This test starts FakeApplication
with the Prod mode and checks the response when FakeRequest
encounters an exception.
FakeApplication
extends an application and is defined...