ましめも

技術系メモ

play framework 2.2でテスト用configを設定する

FakeApplicationで指定のconfigを読み込ませたい場合(例えばconf/test.conf)は次のようにすれば読み込むことができる。

  "テストケース" should {
    "ふがほげ" in {
      running(new FakeApplication with DevSettings {
        def devSettings: Map[String, String] = Map(
          "config.file" -> "conf/test.conf"
        )
      }) {
        // テストコード
      }
    }
  }