23

I have not found any documentation on how to do this. For JUnit the equivalent would be:

mvn -Dtest=org.apache.spark.streaming.InputStreamSuite test
WestCoastProjects
  • 58,982
  • 91
  • 316
  • 560

3 Answers3

38

tl;dr mvn test -Dsuites="some.package.SpecsClass"


I found an answer from here and it works:(https://groups.google.com/forum/#!topic/scalatest-users/Rr0gy61dg-0)

run test 'a pending test' in HelloSuite, and all tests in HelloWordSpec:

 mvn test -Dsuites='org.example.
HelloSuite @a pending test, org.example.HelloWordSpec' 
  • run all tests in HelloSuite containing 'hello':

    mvn test -Dsuites='org.example.HelloSuite hello'

for more details: http://scalatest.org/user_guide/using_the_scalatest_maven_plugin

Jacek Laskowski
  • 72,696
  • 27
  • 242
  • 420
user1132007
  • 406
  • 4
  • 4
22

Found the answer: it is

-DwildcardSuites

So here is the example command line:

mvn -pl streaming -DwildcardSuites=org.apache.spark.streaming.InputStreamSuite test

Update Newer versions of scalatest use

 -Dsuites

So the syntax would be:

mvn -pl streaming -Dsuites=org.apache.spark.streaming.InputStreamSuite test
WestCoastProjects
  • 58,982
  • 91
  • 316
  • 560
18

Note that if you have some Java tests in the same module, as much of spark does, you need to turn them off -which you can do by telling surefire to run a test that isn't there

Here is the test that I've just been running

mvn test -Dtest=moo -DwildcardSuites=org.apache.spark.deploy.yarn.ClientSuite

That skips the java test and only runs the scala one.

One thing which scalatest doesn't seem to do is let you run a single test within a suite, the way maven surefire does. That's not ideal if you have one failing test in a big suite.

[Correction 2016-08-22: looks like you can ask for a specific suite by name; look at the other answers below. Happy to be wrong].

stevel
  • 12,567
  • 1
  • 39
  • 50