Making Maven run all tests, even when some fail

JavaMaven 2Maven Surefire-Plugin

Java Problem Overview


I have a project with several modules. When all tests pass, Maven test runs them all.

When tests fail in the first module, maven will not continue to the next project. I have testFailureIgnore set to true in Surefire settings, but it doesn't help.

How do I make maven run all tests regardless of earlier failures?

Java Solutions


Solution 1 - Java

From the Maven Embedder documentation: > -fae,--fail-at-end Only fail the build afterwards; allow all non-impacted builds to continue > > -fn,--fail-never NEVER fail the build, regardless of project result

So if you are testing one module than you are safe using -fae.

Otherwise, if you have multiple modules, and if you want all of them tested (even the ones that depend on the failing tests module), you should run mvn clean install -fn.
-fae will continue with the module that has a failing test (will run all other tests), but all modules that depend on it will be skipped.

Solution 2 - Java

I just found the -fae parameter, which causes Maven to run all tests and not stop on failure.

Solution 3 - Java

Either configure Surefire with <testFailureIgnore>true</testFailureIgnore>.

Or on the command line:

mvn install -Dmaven.test.failure.ignore=true

Solution 4 - Java

Try to add the following configuration for surefire plugin in your pom.xml of root project:

<project>
  [...]
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <testFailureIgnore>true</testFailureIgnore>
        </configuration>
      </plugin>
    </plugins>
  </build>
  [...]
</project>

Solution 5 - Java

A quick answer:

mvn -fn test

Works with nested project builds.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionripper234View Question on Stackoverflow
Solution 1 - JavadespotView Answer on Stackoverflow
Solution 2 - Javaripper234View Answer on Stackoverflow
Solution 3 - JavaPascal ThiventView Answer on Stackoverflow
Solution 4 - JavanybonView Answer on Stackoverflow
Solution 5 - JavarustyxView Answer on Stackoverflow