简体   繁体   English

在Test中使用fork = false时忽略配置选项

[英]Play 2.3.7 when fork in Test = false config options are ignored

I'm using play 2.3.7 When fork in Test := false in my build.sbt the conf files aren't loaded by play when running tests. 我正在使用play 2.3.7当我在build.sbt fork in Test := false时,在运行测试时,conf文件不会被播放加载。

The line javaOptions in Test += "-Dconfig.file=conf/test.conf" in my build.sbt should load the test.conf when running tests but that's not happening. 我的javaOptions in Test += "-Dconfig.file=conf/test.conf"中的行javaOptions应该在运行测试时加载test.conf但是没有发生。

The workaround is to run activator and pass the above param on the command line like so: 解决方法是运行activator并在命令行上传递上面的参数,如下所示:

activator -Dconfig.file=conf/test.conf "test-only test.integration.SomeTest"

If I remove fork in Test := false then all is good and play finds the conf resources - but then of course I can't step through tests which sucks. 如果我fork in Test := false删除fork in Test := false那么一切都很好并且play找到conf资源 - 但是当然我不能单步执行那些糟糕的测试。

What am I missing in my build.sbt ? 我在build.sbt中缺少什么? Is this a bug in play? 这是一个游戏中的错误吗?

Forking the tests means that you run then on a separate JVM. 分叉测试意味着您在单独的JVM上运行。

Not forking the tests means that they are run in the same JVM as SBT itself and you cannot change the parameters that the JVM was started with after it already has been started. 不分支测试意味着它们在与SBT本身相同的JVM中运行,并且您无法在已经启动后更改JVM启动时的参数。

The only solution if you do not want to fork is to pass all those flags to the JVM that SBT runs on when you start it, just like you mention in the end of your question. 如果您不想分叉,唯一的解决方案是将所有这些标志传递给SBT在启动时运行的JVM,就像您在问题的最后提到的那样。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM