4

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"?
Mark VY
  • 1,489
  • 16
  • 31

1 Answers1

2

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.

Slawomir Jaranowski
  • 7,381
  • 3
  • 25
  • 33
  • fail-at-end won't work for multi-module builds, right? – Mark VY Aug 24 '22 at 17:01
  • seems that ignoring test failures also doesn't help with multi module builds; both facts are documented here: https://stackoverflow.com/questions/4174696/making-maven-run-all-tests-even-when-some-fail – Mark VY Aug 24 '22 at 21:56
  • ok --fail-at-end skip build of modules which depends on failed module – Slawomir Jaranowski Aug 25 '22 at 16:14
  • Yes, it does, which makes sense in a way. But the other option seems like it SHOULD work. I'm not sure why it doesn't. – Mark VY Aug 25 '22 at 19:34
  • Upon closer inspection, it seems that it perhaps DOES work. Maybe I was wrong all along. – Mark VY Aug 30 '22 at 16:06
  • No, seems like I was right... it does not quite run the whole build. Need to stare at this some more maybe. – Mark VY Aug 30 '22 at 16:15
  • I think I get it; it's compiling all modules but not running all tests, which misled me at first. – Mark VY Aug 30 '22 at 19:23
  • also you can add false or true in configuration section of plugin inside pom.xml – Lety Sep 05 '22 at 11:35
  • yep, thanks, knew about that; same thing as setting via property, but good to have it mentioned – Mark VY Sep 06 '22 at 14:49