1
私は、プレイフレームワークバージョン2.5.9のコントローラの機能テストをしようとしています。機能テストでコントローラをテストする方法
私は
@Singleton
class HomeController @Inject()(implicit exec: ExecutionContext) extends Controller {
def index = Action.async {
Future{
Ok(views.html.index("Home"))
}
}
}
私の見解は@mainでこの
@(message: String)
@main("Home") {
<h2>Welcome</h2>
}
引数のように見えるにHomeControllerと呼ばれるコントローラをページ のタイトルで何が起こっている必要があり、私のテストでは、このようになります
class ApplicationTwoSpec extends PlaySpec with OneServerPerSuite with OneBrowserPerSuite with HtmlUnitFactory{
implicit val ec = Implicits.global
val homeController = new HomeController()
implicit override lazy val app =
new GuiceApplicationBuilder()
.router(Router.from{
case GET(p"/") => homeController.index
})
.build()
"The sample Controler with a server" must {
"have home in the title" in {
go to s"http://localhost:9000/"
pageTitle mustBe "Home"
}
}
}
私がテストを実行したときに戻る
must return and ok response back *** FAILED ***
"[]" was not equal to "[Home]" (ApplicationTwoSpec.scala:37)
適切な応答を得るには何が必要ですか?