16

How do I pass command line arguments to ScalaTest using its maven plugin? I was looking for something like TestNG's delegateCommandSystemProperties configuration, but the closest I could find in ScalaTest documentation were:

  • argLine: Option to specify additional JVM options to pass to the forked process
  • environmentVariables: Additional environment variables to pass to the forked process
  • systemProperties: Additional system properties to pass to the forked process

But isn't this redundant? For example if I want to pass environment=development, I need to specify the following in pom.xml:

<plugin>
  <groupId>org.scalatest</groupId>
  <artifactId>scalatest-maven-plugin</artifactId>
  <configuration>
    <argLine>-Denvironment=${env}</argLine>
  </configuration>
</plugin>

and then run mvn test -Denv=development. Is there a simpler way to pass command line arguments to ScalaTest directly?

zihaoyu
  • 5,483
  • 11
  • 42
  • 46

1 Answers1

7

There is no need for defining <argLine> in the pom. But it's surely not intuitive to figure, nor well documented, just need to add a simple example usage into the docs.

All you need for passing system properties to a maven test is: test -Dsuites=com.company.somepackage.SomeSpec "-DargLine=-Denv=env001 -Dgroup=default -DmaxTests=10".

For environmentVariables and systemProperties - there has got to be a simple syntax that works too. Should be possible to figure from either trial and error or reading the source code if anyone's interested. For my needs argLine is enough.

arntg
  • 1,557
  • 14
  • 12