How to run Java Spring Boot mvn integration tests in parallel using Azure Pipelines

I am trying to parallelise the executions of long-running integration tests.

At the moment tests are ran using a specific profile:

<profile>
    <id>integration-test</id>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>3.1.2</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                        </goals>
                        <configuration>
                            <includes>
                                <include>**/workflow/*IntegrationTest.java</include>
                            </includes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</profile>

And I run those using:
mvn clean -P integration-test verify

All working as expected, only classes ending with IntegrationTest.java in workflow folder are being tested.

My next step would be to run classes that are beginning with letters A to M and ending with the same pattern using a specific profile.
So I tried:

<profile>
    <id>integration-test-from-n-to-z</id>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>3.1.2</version>
                <executions>
                    <execution>
                        <configuration>
                            <goal>
                                integration-test
                            </goal>
                            <includes>
                                <include>**/workflow/[A-M]*IntegrationTest.java</include>
                            </includes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</profile>

I think I got the RegEx syntax wrong.
I checked and it should be using %regex[[A-M]] so I also tried that but then the test won’t even start returning a regex error.

So I tried to simplify even more creating a profile that runs a single test:

<profile>
    <id>integration-test-from-n-to-z</id>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>3.1.2</version>
                <executions>
                    <execution>
                        <configuration>
                            <goal>
                                integration-test
                            </goal>
                            <includes>
                                <include>**/workflow/LaptopIntegrationTest.java</include>
                            </includes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</profile>

And still all I got was unit tests running but no integration test.

What am I doing wrong?
Is this maybe the wrong way to achieve this goal?

Leave a Comment