LoginSignup
20

More than 5 years have passed since last update.

play test 実行時に指定したconfファイルを読み込む

Last updated at Posted at 2014-02-26

環境

  • Mac OSX Version 10.8.5
  • Play Framework 2.2.1

手順

conf/以下にtest.confを作る。

shell
$ touch conf/test.conf

test.confにてapplication.confを読み込み、上書きしたい設定を記述する。

shell
$ vi conf/test.conf
include "application.conf"

db.default.url="jdbc:mysql://database.localdomain/test_database" 

build.sbtのjavaOptionsにテスト環境の時に読み込むconfファイルを指定する。

shell
$ vi build.sbt
javaOptions in Test += "-Dconfig.file=conf/test.conf"

参考

コマンドラインで$ play -Dconfig.file=test.conf testとしても読み込まれなかったので、以下サイトを参考にして読み込まれるようにした。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
20