Surefire按顺序运行某些测试,其他并行运行 [英] Surefire run certain tests in sequence, others in parallel

查看:73
本文介绍了Surefire按顺序运行某些测试,其他并行运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种方法可以使JUnit的surefire插件按顺序运行某些测试?当前它正在并行运行所有测试,但是有些测试很难转换,如果不并行运行就足够了.这是我们pom.xml的一部分:

Is there a way to make certain tests run in in sequence with the surefire plugin for JUnit? Currently it is running all tests in parallel, but some tests are very hard to convert and it would be sufficient if they didn't run in parallel. Here is a part of our pom.xml:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.17</version>
    <dependencies>
      <dependency>
        <groupId>org.apache.maven.surefire</groupId>
        <artifactId>surefire-junit47</artifactId>
        <version>2.17</version>
      </dependency>
    </dependencies>
    <configuration>
        <parallel>all</parallel>
        <threadCount>8</threadCount>
      <includes>
        <include>${includeTest}</include>
        <include>${includeAdditionalTest}</include>
      </includes>
    </configuration>
</plugin>

推荐答案

咨询

Consult the surefire plugin documentation. It provides a way to specify that certain tests are not thread safe by using @NotThreadSafe annotation.

另一种解决方案是使用显式测试包含项和排除项.一个执行可以在并行模式下运行,其中包括线程安全套件,而另一个则是非线程安全的.

Another solution is to specify two separate surefire executions with explicit test inclusions and exclusions. One execution could run in parallel mode including the thread safe suites, the other those non thread safe.

这篇关于Surefire按顺序运行某些测试,其他并行运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆