Reputation: 3771
I have an IntegrationSpec using Selenium in Play Framework 2.2.0 that I would like to run against multiple environments.
First obvious choice is to pass the environment as system property through command line:
play -Denv=test1 "test-only integration.IntegrationSpec"
But above does not work in Play 2.2. When in test, I try to read it as follows and the value returned is null
.
System.getProperty("env")
I see the exact question being asked here but the answer is for older versions. In 2.2 it does not seem to work anymore.
Is there another way to set this property that I can use it in my test?
Upvotes: 1
Views: 354
Reputation: 3294
My understanding is that tests run in forked JVM and that's why the property is not set. You may pass the "env" parameter by adding following to your build.sbt:
javaOptions in Test += "-Denv=" + Option(System.getProperty("env")).getOrElse("default")
Upvotes: 2