How to run scalatest in parallel with maven surefire plugin?
Asked Answered
S

1

9

I'm working on a scala project which use Maven to build and maven-surefire-plugin to run the tests written in scalatest.

The tests are like:

import org.scalatest.ParallelTestExecution

@RunWith(classOf[org.scalatest.junit.JUnitRunner])
class MyTest extends FunSuite with ParallelTestExecution {
   // some tests
}

From some questions, I know that if we give a -P argument to scalatest, it will run the tests in parallel.

But I'm not sure how to configure it with maven-surefire-plugin, I tried to add -P, but which causes the JVM unable to start:

<plugin>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
        <argLine>-P</argLine>
    </configuration>
</plugin>

Is there any way to do it? If we can't do it with maven surefire plugin, is it possible to configure it just in tests?

Sundries answered 22/9, 2015 at 7:47 Comment(0)
C
0

If all of your tests are written with scalatest, you should be using the scalatest maven plugin rather than surefire. There's

doc: http://www.scalatest.org/user_guide/using_the_scalatest_maven_plugin

source: https://github.com/scalatest/scalatest-maven-plugin

Chaldron answered 7/12, 2016 at 21:39 Comment(3)
Note that if you do use the scalatest maven plugin then you can't use java testing in your code. If you have mixed java/scala project then using surefire and decorating with @RunWith is the only way I know ofChiffchaff
@AssafMendelson To be more clear, you still can test Java but using scalatest.Hotblooded
This found all of the tests in my project that extend from PlaySpec (from ScalaTestPlus-Play, and that extends from something in scalatest), but not Specification (from Play-Spec2).Nearly

© 2022 - 2024 — McMap. All rights reserved.