0

We've recently upgraded from Maven 2.2.1 to Maven 3.5.3.

We used to run the unit tests for some of our projects/modules using the parallel test functionality in the maven-surefire-plugin. Specifically, we had one module that was configured as follows:

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.21.0</version>
    <configuration>
      <argLine>-Xmx5G</argLine>
      <failIfNoTests>false</failIfNoTests>
      <printSummary>true</printSummary>
      <reportFormat>plain</reportFormat>
      <parallel>all</parallel>
      <useUnlimitedThreads>true</useUnlimitedThreads>
    </configuration>
  </plugin>

However, since upgrading to Maven 3.5.3, we've found that the build stalls or hangs somewhere in running the unit tests for that module.

Since then, we've also found that if we remove the <parallel> and <useUnlimitedThreads>, the build works fine.

Incidentally, it also seems that, with that configuration, whether the unit tests are run in parallel depends on the -T X parallel build configuration - i.e. if I specify -T 20, doing a build on that single module seems to run substantially faster than without specifying the parallel build, which may suggest that Maven 3 is using that parallel build configuration to run the tests in parallel - although, that's not what I understood to be the case from the parallel builds documentation.

I've tried various permutations of the maven-surefire-plugin configuration, but none of them in which I include <parallel> work for that module.

Questions:

  • Should I be able to run tests with <parallel> in Maven 3.5.3?

  • If so, is there any additional configuration that I should be using to get this to work?

  • Are there any known issues with running tests with <parallel> in Maven 3.5.3? (I've done a pretty extensive search for this, but it may be that someone knows of something that I haven't been able to find.)

  • Is there some interaction between maven 3 parallel builds and running tests in parallel?

amaidment
  • 6,942
  • 5
  • 52
  • 88
  • First I would investigate the unit test if those tests are real unit tests and not covered integration test which can't be parallelized etc. so configuring maven to run in single thread mode and configure surefire to use multiple threads first....have you upgraded all plugins to newest versions etc. ? – khmarbaise Apr 11 '18 at 09:17
  • @khmarbaise - yes, all plugins on latest versions. All tests can be parallelized (suites/classes/methods) - indeed, they were all working as such with maven 2.2.1. – amaidment Apr 11 '18 at 09:27
  • If they have worked with Maven 2.2.1 does not mean they are real unit tests (cause they have run single threaded)..furthermore if you are using suites which is usually not a good idea related to surefire/failsave usage.... – khmarbaise Apr 11 '18 at 09:29
  • @khmarbaise - can you elaborate on your previous comment? What do you mean "they are not real unit tests" - and what do you mean by a "real unit test"? Also, why are test suites (i.e. using @RunWith) not a good idea with surefire? – amaidment Apr 11 '18 at 10:50

0 Answers0