[英]Pass System Properties in Play Framework Test with Activator
Play framework uses Play框架使用
activator test
to run all tests. 运行所有测试。
How do I pass Java System properties to my test cases. 如何将Java System属性传递给我的测试用例。 The following won't work
以下方法无效
activator -Dsettings="/settings/settings.json" test
Coincidentally, the above will work if I am using the ~run
command instead. 巧合的是,如果我使用
~run
命令,上面的内容将会起作用。
I've already read this question, but it is only valid for the play
command 我已经阅读过这个问题了,但它只对
play
命令有效
I think I found a solution (Play 2.3.8) 我想我找到了一个解决方案(Play 2.3.8)
In build.sbt add something like this: 在build.sbt中添加如下内容:
javaOptions in Test += "-Dsettings=" + Option(System.getProperty("settings")).getOrElse("default.json")
then 然后
activator -Dsettings="/settings/settings.json" test
can override the settings
key 可以覆盖
settings
键
Disclaimer: I tested this for testserver.port
, not for settings
免责声明:我测试了
testserver.port
,而不是settings
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.