vendredi 12 février 2021

Running tests in parallel with maven surefire plugin

Recently got a new job, I'm working on a Maven and Micronaut project - I'm new to Maven, 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>

Aucun commentaire:

Enregistrer un commentaire