Reputation: 899
Recently got a new job, I'm working on a Maven and Micronaut project - I'm new to Micronaut, and if you're not familiar, its an alternative to Spring.
Using this as a guide: https://www.baeldung.com/maven-junit-parallel-tests
I'm trying to get our integration tests to run in parallel, in an attempt to speed up our tests. I have added the required configuration to the pom.xml file. I have tweaked this lots, with different combinations of settings (including ones I found on other SO posts).
But when I run the tests, with and without this added config, the time it takes to run them is exactly the same - 1 minute and 38 seconds. So I don't think its working. Although don't know what my expected output on the console should look like if it is working?
In the tests, none of them are using @RunWith, its using the default, which should be okay.
This is the pom. Can anyone advise please? Thanks.
<profiles>
<profile>
<id>integration</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludedGroups>unit, performance</excludedGroups>
<parallel>classes</parallel>
<threadCount>10</threadCount>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>performance</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludedGroups>unit, integration</excludedGroups>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>all</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludedGroups>none</excludedGroups>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<build>
<plugins>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<excludedGroups>integration, performance</excludedGroups>
<parallel>classes</parallel>
<threadCount>10</threadCount>
</configuration>
</plugin>
...
</plugins>
</build>
Upvotes: 10
Views: 12065
Reputation: 1554
Could you please try with the configuration option forkCount
?
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
...
<forkCount>4</forkCount>
...
</configuration>
</plugin>
From the official xml element description
Option to specify the number of VMs to fork in parallel in order to execute the tests. When terminated with "C", the number part is multiplied with the number of CPU cores. Floating point value are only accepted together with "C". If set to "0", no VM is forked and all tests are executed within the main process.
Example values: "1.5C", "4"
Upvotes: 2
Reputation: 314
I had the same problem and tried every combination of:
maven-surefire-plugin (version 2.22.0)
maven-failsafe-plugin (version 2.22.0)
The parallel/threadCount configuration you mention.
These different plugin configurations specified at https://junit.org/junit5/docs/current/user-guide/#running-tests-build-maven-config-params and https://junit.org/junit5/docs/current/user-guide/#writing-tests-parallel-execution. As in this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.0</version>
<configuration>
<properties>
<configurationParameters>
junit.jupiter.execution.parallel.enabled=true
junit.jupiter.execution.parallel.mode.default=same_thread
junit.jupiter.execution.parallel.mode.classes.default=concurrent
</configurationParameters>
</properties>
</configuration>
</plugin>
The only combination that worked was 2 (maven-failsafe-plugin) and 4 (configurationParameters).
Upvotes: 4