4

I configured build.sbt for the unit test to use a different Play (2.3.9 for Scala and SBT 0.13.5) configuration via,

javaOptions in Test ++= Seq("-Dconfig.file=/home/kitty/acme/test/resources/test-application.conf")

Play did not pick up test-application.conf and used application.conf in conf instead. AFAIK, there is no scalaOption in this case. However, if I include -Dconfig.file in the command line, it works fine,

sbt test -Dconfig.file=/home/kitty/acme/test/resources/test-application.conf

How do I fix this? Thanks.

2 Answers 2

11

javaOptions in Test ++= Seq("-Dconfig.file=/home/kitty/acme/test/resources/test-application.conf") didn't work because my fork in Test was false. Therefore, set fork to true and it will work. -Dconfig.resource like -Dconfig.file works the same way too. SBT will not pick it up if it is not forked. Strictly, javaOptions only work with fork is true as mentioned here

1

you're almost there, you can force JVM options like this

javaOptions in Test ++= Seq("-Dconfig.file=/home/kitty/acme/test/resources/test-application.conf")

config.file also takes a relative path e.g conf/test-application.conf

5
  • No. It does not work. It causes "Seq[String] cannot be appended to Seq[sbt.TestOption]" error during SBT reload. Then I try testOptions in Test ++= Seq(Tests.Argument("-Dconfig.file=/home/kitty/test/resources/test-application.conf")), SBT continues but test-application.conf is not read.
    – thlim
    Commented Oct 28, 2015 at 17:19
  • my bad, typo in the answer. It's javaOptions, i'll amend
    – w4tson
    Commented Oct 28, 2015 at 17:24
  • Is it not what I say that didn't work in my question?
    – thlim
    Commented Oct 28, 2015 at 17:27
  • I've just re-read, sorry you're right. This is working for me on 2.3.x and 2.4.x however i'm using a relative path from the conf/ directory, could you try that?
    – w4tson
    Commented Oct 28, 2015 at 17:28
  • still no good. does it has something to do with fork in Test := false and parallelExecution in Test := false?
    – thlim
    Commented Oct 28, 2015 at 17:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.