Ida Amit
Ida Amit

Reputation: 1687

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:

Upvotes: 3

Views: 4291

Answers (1)

khmarbaise
khmarbaise

Reputation: 97359

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.

Upvotes: 4

Related Questions