javadba javadba - 15 days ago 10
Scala Question

How to set System property for a scalatest from sbt command line

A ScalaTest suite is using

System.getProperty("my.command-line.property")


What is the sbt command line to achieve this setting?

I have tried

SBT_OPTS="-Dmy.command-line.property=foo" sbt "test-only <path to test suite"


Also:

JAVA_OPTS="-J-Dmy.command-line.property=foo" sbt "test-only <path to test suite"


Finally:

sbt/sbt '; set javaOptions in Test +="-Dtest.num.points=500000"; \
project mllib; test-only org.apache.spark.mllib.optimization.LBFGSSuite'


When using any of those attempts the System.getProperty comes up blank.

An approach that does work is running the ScalaTest from within Intellij and setting the JVM parameters to -Dmy.command-line.property=foo within the Run Configuration.

Answer

Your third way almost works (if fork in Test := true is set). But you have to change into the project first:

sbt/sbt  '; project mllib; set javaOptions in Test  +="-Dtest.num.points=500000"; \
test-only org.apache.spark.mllib.optimization.LBFGSSuite'
Comments