Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set javaOptions in Test for Play/SBT

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.

like image 514
thlim Avatar asked Dec 19 '22 22:12

thlim


2 Answers

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

like image 129
thlim Avatar answered Jan 01 '23 16:01

thlim


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

like image 41
w4tson Avatar answered Jan 01 '23 15:01

w4tson