Playframework 在'中使用规格2;是';风格与游戏2

Playframework 在'中使用规格2;是';风格与游戏2,playframework,playframework-2.0,specs2,Playframework,Playframework 2.0,Specs2,HashIdGenerator需要播放应用程序启动,播放文档显示我们需要通过以下方式获得播放应用程序: 但我不喜欢这种“应在”样式,因此如何获得播放应用程序并同时继续使用“是”样式。使用WithApplication包装代码取决于播放应用程序: "Computer model" should { "be retrieved by id" in new WithApplication { // your test code } "be retrieved by email

HashIdGenerator需要播放应用程序启动,播放文档显示我们需要通过以下方式获得播放应用程序:


但我不喜欢这种“应在”样式,因此如何获得播放应用程序并同时继续使用“是”样式。

使用WithApplication包装代码取决于播放应用程序:

  "Computer model" should {

  "be retrieved by id" in new WithApplication {
    // your test code
  }
  "be retrieved by email" in new WithApplication {
    // your test code
  }
}
  "Computer model" should {

  "be retrieved by id" in new WithApplication {
    // your test code
  }
  "be retrieved by email" in new WithApplication {
    // your test code
  }
}
  val Id = 1
  val app = new WithApplication {
    val hashId = HashIdGenerator.hashId(Id)
  }
  val hashId = app.hashId