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

查看:37
本文介绍了如何为 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 正在使用 forked 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天全站免登陆