maven-failsafe-plugin does not execute test cases

2019-09-14 20:08发布

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

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>    

1条回答
不美不萌又怎样
2楼-- · 2019-09-14 20:13

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

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

Internally maven-failsafe-plugin downloads maven-surefire-plugin 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> 

Working 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>

查看更多
登录 后发表回答