如何为sbt测试指定sbt 0.12.2的配置文件? [英] How do I specify a config file with sbt 0.12.2 for sbt test?
问题描述
我有戏!项目与单元测试,我试图使用sbt在我的登台环境中运行测试.在升级到Play 2.1之前,当我使用Play 2.0.4和sbt 0.11.3时,我可以做$ sbt -Dconfig.file=conf/staging.conf test
.现在,无论我为-Dconfig.file指定什么,sbt test
似乎都使用默认的application.conf.
I have a Play! project with unit tests and I am trying to run tests on my staging environment using sbt. Before I upgraded to Play 2.1, when I was using Play 2.0.4 and sbt 0.11.3 I could do $ sbt -Dconfig.file=conf/staging.conf test
. Now sbt test
seems to use the default application.conf no matter what I specify for -Dconfig.file.
sbt start -Dconfig.file=conf/staging.conf
仍然可以正常工作.这种行为是sbt 0.12.2的错误,还是我应该指定一个配置文件以其他方式运行测试?
sbt start -Dconfig.file=conf/staging.conf
still works fine. Is this behavior a bug with sbt 0.12.2 or should I be specifying a config file for running tests in a different way?
推荐答案
test正在使用派生的jvm. 使用javaOptions sbt设置将jvm选项传递给它,例如
test is using forked jvm. Use javaOptions sbt setting to pass jvm options to it e.g.
javaOptions ++= Seq("-Dconfig.file=conf/staging.conf")
或
javaOptions ++= collection.JavaConversions.propertiesAsScalaMap(System.getProperties).map{ case (key,value) => "-D" + key + "=" +value }.toSeq
这篇关于如何为sbt测试指定sbt 0.12.2的配置文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!