我为单元测试配置了 build.sbt 以使用不同的 Play(2.3.9 for Scala 和 SBT 0.13.5)配置,
javaOptions in Test ++= Seq("-Dconfig.file=/home/kitty/acme/test/resources/test-application.conf")
Play 没有选择
test-application.conf
,而是在 application.conf
中使用了 conf
。 AFAIK,在这种情况下没有 scalaOption
。但是,如果我在命令行中包含 -Dconfig.file
,它就可以正常工作,sbt test -Dconfig.file=/home/kitty/acme/test/resources/test-application.conf
我该如何解决?谢谢。
最佳答案
javaOptions in Test ++= Seq("-Dconfig.file=/home/kitty/acme/test/resources/test-application.conf")
不起作用,因为我的 fork in Test
是 false
。因此,将 fork
设置为 true
它将起作用。 -Dconfig.resource
与 -Dconfig.file
的工作方式相同。如果没有 fork ,SBT 不会捡起它。严格地说,javaOptions
只适用于 fork
是 true
,正如提到的 here
关于scala - 在测试中设置 javaOptions for Play/SBT,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33389655/