Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ScalaTest: pass command line arguments to ScalaTest maven goal

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?

like image 973
zihaoyu Avatar asked Apr 11 '13 15:04

zihaoyu


People also ask

What is ScalaTest Maven plugin?

The ScalaTest Maven plugin allows you to run ScalaTest tests through Maven without requiring @RunWith(classOf[JUnitRunner]) annotations and access all functionality of the ScalaTest Runner , including parallel execution and multiple reporters.


1 Answers

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.

like image 105
arntg Avatar answered Sep 19 '22 01:09

arntg