如何与 maven surefire 插件并行运行 scalatest?

Fre*_*ind 7 maven scalatest parallel-testing maven-surefire-plugin

我正在开发一个使用 Maven 构建和maven-surefire-plugin运行在 Scalatest 中编写的测试的 Scala 项目。

测试是这样的:

import org.scalatest.ParallelTestExecution

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

从一些问题中,我知道如果我们给-Pscalatest一个参数,它将并行运行测试。

但是我不确定如何使用 配置它maven-surefire-plugin,我尝试添加 -P,但这导致 JVM 无法启动:

<plugin>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
        <argLine>-P</argLine>
    </configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)

有什么办法吗?如果我们不能用 maven surefire 插件来做,是否可以只在测试中配置它?

Jef*_*ley 0

如果所有测试都是用 scalatest 编写的,那么您应该使用 scalatest maven 插件而不是 Surefire。有

文档: http: //www.scalatest.org/user_guide/using_the_scalatest_maven_plugin

来源: https: //github.com/scalatest/scalatest-maven-plugin

  • 请注意,如果您确实使用 scalatest maven 插件,那么您将无法在代码中使用 java 测试。如果您混合了 java/scala 项目,那么使用 Surefire 并用 @RunWith 进行装饰是我所知道的唯一方法 (4认同)