How to compile all maven modules even if tests fail, but fail overall build if any tests fail
maven, testing
Solution
I would suggest to use:
mvn -Dmaven.test.failure.ignore=true --fail-at-end clean install
Problem
Context: I want to compile and test all modules in a multi-module project but if any fail either compilation or tests I want the overall build to fail. Default configurations either stop on the first failure or skip modules after a test failure Running: mvn clean install stops at the first failing module. If you add: mvn clean install -fae //fail at end then all modules are run, but if tests fail then any dependent modules are skpped: ``` [INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary: [INFO] ------------------------------------------------------------------------ [INFO] Module A ............................................. SUCCESS [15.210s] [INFO] Module B ............................................. SUCCESS [10.923s] [INFO] Module C ............................................. FAILED [1.731s] [INFO] Module D ............................................. SUCCESS [3.791s] [INFO] Module E ............................................. SUCCESS [1.488s] [INFO] Module F ............................................. SKIPPED (dependency build failed or was skipped) [INFO] Module G ............................................. SKIPPED (dependency build failed or was skipped) [INFO] Module H ............................................. SKIPPED (dependency build failed or was skipped) [INFO] Module I ............................................. SUCCESS [1.690s] [INFO] ----------------------------------------- ``` Another option to force all modules to compile is: mvn clean install -fn //fail never but this results in the build passing when tests fail ``` [INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary: [INFO] ------------------------------------------------------------------------ [INFO] Module A ............................................. SUCCESS [15.210s] [INFO] Module B ............................................. SUCCESS [10.923s] [INFO] Module C ............................................. FAILED [1.731s] [INFO] Module D ............................................. SUCCESS [3.791s] [INFO] Module E ............................................. SUCCESS [1.488s] [INFO] Module F ............................................. SUCCESS [9.062s] [INFO] Module G ............................................. SUCCESS [16.324s] [INFO] Module H ............................................. SUCCESS [4.032s] [INFO] Module I ............................................. SUCCESS [1.690s] [INFO] ------------------------------------------------------------------------ [INFO] Error for project: Module C (during install) [INFO] ------------------------------------------------------------------------ [INFO] There are test failures. Please refer to C:\MavenBuildDir\ModuleC\surefire-reports for the individual test results. [INFO] ------------------------------------------------------------------------ [INFO] For more information, run Maven with the -e switch [INFO] ------------------------------------------------------------------------ [INFO] + Ignoring failures [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESSFUL [INFO] ------------------------------------------------------------------------ [INFO] Total time: 30 minutes 38 seconds [INFO] Finished at: Fri May 23 16:42:08 BST 2014 [INFO] Final Memory: 39M/185M ``` Can anyone advise a set of options to achieve the following: - compile all modules - run tests on all modules - If a module's tests fail but the code compiles dependent modules still get compiled and tested Responses much appreciated - otherwise we have to run the tests repeatedly on the build server if there are multiple issues - burning a lot of time.