Making Maven run all tests, even when some fail

后端 未结 5 1891
深忆病人
深忆病人 2020-11-29 15:18

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 projec

相关标签:
5条回答
  • 2020-11-29 15:43

    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>
    
    0 讨论(0)
  • 2020-11-29 15:46

    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.

    0 讨论(0)
  • 2020-11-29 15:48

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

    0 讨论(0)
  • 2020-11-29 15:57

    A quick answer:

    mvn -fn test
    

    Works with nested project builds.

    0 讨论(0)
  • 2020-11-29 16:00

    Can you test with surefire 2.6 and either configure surefire with testFailureIgnore=true. Or on the command line:

    mvn install -Dmaven.test.failure.ignore=true
    
    0 讨论(0)
提交回复
热议问题