如何为sbt测试指定sbt 0.12.2的配置文件? [英] How do I specify a config file with sbt 0.12.2 for sbt test?

查看:83
本文介绍了如何为sbt测试指定sbt 0.12.2的配置文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有戏!项目与单元测试,我试图使用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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆