简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM