简体   繁体   中英

Pass System Properties in Play Framework Test with Activator

Play framework uses

activator test

to run all tests.

How do I pass Java System properties to my test cases. The following won't work

activator -Dsettings="/settings/settings.json" test

Coincidentally, the above will work if I am using the ~run command instead.

I've already read this question, but it is only valid for the play command

I think I found a solution (Play 2.3.8)

In build.sbt add something like this:

javaOptions in Test += "-Dsettings=" + Option(System.getProperty("settings")).getOrElse("default.json")

then

activator -Dsettings="/settings/settings.json" test

can override the settings key

Disclaimer: I tested this for testserver.port , not for settings

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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