May 2015
Intermediate to advanced
274 pages
5h 11m
English
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 ...
Read now
Unlock full access