How do I specify a config file with sbt 0.12.2 for sbt test?

和自甴很熟 提交于 2019-11-28 23:36:44

test is using forked jvm. Use javaOptions sbt setting to pass jvm options to it e.g.

javaOptions ++= Seq("-Dconfig.file=conf/staging.conf")
or

javaOptions ++= collection.JavaConversions.propertiesAsScalaMap(System.getProperties).map{ case (key,value) => "-D" + key + "=" +value }.toSeq

Similar approach is to just pass the config file to use, while triggering the sbt test

First, in the Build.scala file

val testOptions = "-Dconfig.file=conf/" + Option(System.getProperty("test.config")).getOrElse("application") + ".conf"

val main = PlayProject(appName, appVersion, appDependencies, mainLang = SCALA).settings(
    javaOptions in Test += testOptions
)

Then, in the command line to run the test with integ.conf

sbt -Dtest.config=integ test

to use the default application.conf

sbt test 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!