【问题标题】:How to run scalatest in parallel with maven surefire plugin?如何与 maven surefire 插件并行运行 scalatest?
【发布时间】:2015-12-19 02:23:13
【问题描述】:

我正在开发一个使用 Maven 构建并使用maven-surefire-plugin 运行以 scalatest 编写的测试的 scala 项目。

测试是这样的:

import org.scalatest.ParallelTestExecution

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

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

但是我不知道怎么配置maven-surefire-plugin,我尝试添加-P,但是导致JVM无法启动:

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

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

【问题讨论】:

    标签: maven scalatest maven-surefire-plugin parallel-testing


    【解决方案1】:

    如果您所有的测试都是用 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 装饰是我知道的唯一方法
    猜你喜欢
    • 2021-05-16
    • 1970-01-01
    • 2018-05-26
    • 2016-02-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多