Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sbt test-only not picking up jvm option when forking a jvm for tests

Tags:

scala

sbt

I have the following lines in my build.sbt

fork := true

javaOptions in run += "-Dmy.environment=local"

javaOptions in test += "-Dmy.environment=local"

This works totally fine when I use the "test" command in sbt and when my code checks the jvm system settings for my.environment, it finds the correct value (i.e., "local").

The problem that I am having is that when I run "test-only org.whatever.SomeTest" in this case the my.environment key isn't in the jvm system settings. Specifically, System.getProperty("my.environment") is null whereas it was "local" when I just ran "test".

Does anyone know how to fix this?

like image 919
chuck taylor Avatar asked Oct 22 '22 04:10

chuck taylor


1 Answers

You are likely hitting #975: regression: fork in test doesn't work anymore, which is currently under review. Try:

javaOptions in Test += "-Dmy.environment=local"
like image 134
Eugene Yokota Avatar answered Nov 15 '22 05:11

Eugene Yokota