mavenunit-testingmaven-surefire-plugincucumber-junitparallel-testing

maven-surefire-plugin doesnot work in SpringBoot 2.2.2.RELEASE and above


I have used maven-surefire-plugin in my Maven project to execute the tests in parallel. everything work great. When I have upgraded to SpringBoot 2.2.2.RELEASE and above, tests stop running in parallel. This is how I use the plugin :

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>3.0.0-M4</version>
        <configuration>
            <parallel>methods</parallel>
            <useUnlimitedThreads>true</useUnlimitedThreads>
        </configuration>
    </plugin>

Is there a way to execute tests in parallel ? with this plug-in ?
I have uploaded a small maven project with two modules:


Solution

  • Creating a configuration in pom:

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <artifactId>junit-jupiter</artifactId>
                    <groupId>org.junit.jupiter</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>junit-vintage-engine</artifactId>
                    <groupId>org.junit.vintage</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>mockito-junit-jupiter</artifactId>
                    <groupId>org.mockito</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13</version>
        </dependency>
    

    The problem here is of course that you are using JUnit 4 only.