Search code examples
mavenmaven-surefire-pluginmaven-compiler-plugin

how to get maven to run all tests but still fail build on compile error


Suppose I have a multi-module maven project. I want to run it in such a way that:

  • If a test fails, I still want to compile and test the next module. This sounds like a job for --fail-never, but see below.
  • If there are test failures, I don't really care if the build succeeds or fails. Ideally this would be configurable, but whatever.
  • If there are compiler errors, then the build should fail. I think this rules out "fail-never"?

Solution

  • You can use surefire parameter: maven.test.failure.ignore

    mvn test -Dmaven.test.failure.ignore
    

    With this options failing test will not fail build a module and finally whole build will have success result.