Maven-failsafe-plugin不以并行模式执行单个类的测试用例 [英] maven-failsafe-plugin does not execute test cases from single class in parallel mode

查看:152
本文介绍了Maven-failsafe-plugin不以并行模式执行单个类的测试用例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含多个测试用例的测试类,我想在并行模式下执行.

I've single test class with multiple test cases, which I would like to execute in parallel mode.

我在pom.xml中进行了设置

I've below setup in pom.xml

但是不是按并行方式执行,而是按顺序执行测试用例.

But instead of executing in parallel mode, test cases are being executed in sequence.

请澄清这里可能出了什么问题?

Please clarify what may be going wrong here ?

<plugin>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>2.18.1</version>
            <configuration>
                <forkCount>3</forkCount>
                <reuseForks>true</reuseForks>            
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>integration-test</goal>
                        <goal>verify</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>    

推荐答案

在maven-failsafe-plugin中直接添加并行配置不起作用(可能是一个错误.)

Directly adding parallel configuration in maven-failsafe-plugin is not working (May be a bug.)

但是我们可以在surefire插件配置中设置并行属性和线程数.

But we can set parallel attribute and thread count in surefire plugin configuration.

内部 maven-failsafe-plugin 下载 maven-surefire-plugin 插件.

因此,我们可以显式提供对具有并行配置的maven-surefire-plugin的依赖.

So we can explicitly provide dependency on maven-surefire-plugin having parallel configuration.

我已经测试过,方法正在并行执行.

I have tested , method are getting executed in parallel.

有关如何并行运行测试用例以及更多配置参数的更多信息,请单击

For more know how on running testcase in parallel and more configuration parameters click here.

             <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.19.1</version>
                <configuration>
                    <forkCount>3</forkCount>
                    <reuseForks>true</reuseForks>
                    <parallel>methods</parallel>
                    <useUnlimitedThreads>true</useUnlimitedThreads>
                </configuration>
             <plugin> 

工作pom.

<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-module</artifactId>
<version>1</version>


<dependencies>

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>test</scope>
    </dependency>



</dependencies>

<build>
    <plugins>

        <plugin>

            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.19.1</version>
            <configuration>
                <forkCount>3</forkCount>
                <reuseForks>true</reuseForks>
                <parallel>methods</parallel>
                <useUnlimitedThreads>true</useUnlimitedThreads>
            </configuration>

        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>2.19.1</version>

        </plugin>


        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
        </plugin>

    </plugins>

</build>

这篇关于Maven-failsafe-plugin不以并行模式执行单个类的测试用例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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