Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to set system properties by using -D when running Scalatest in a Maven project

I am new to Scala and Maven, we are starting to use Scalatest to do pre deployment tests for a Java project. We are using maven-scala-plugin to run the tests, and we want to read some parameters (properties) off the command line to run the test, for example:

mvn test -Dparam1=value1 -Dparam2=value

however the problem is that when we use System.getProperty("param1") in tests it gives back null, which should be value1.

Any advices will be appreciated!

like image 416
user1154653 Avatar asked Feb 06 '12 17:02

user1154653


1 Answers

I suspect this is because maven forks the process and creates a new JVM to run the tests in. You can disable forking by running it like mvn -DforkMode=never.

like image 133
Abhinav Sarkar Avatar answered Sep 21 '22 09:09

Abhinav Sarkar