Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run a maven goal when there is tests failures?

I would like to know if there is a way to execute a goal when there is test failures?

Since maven stops its execution (fail fast mode) after encountering a test failure, is there any options to launch a goal when there is test failures?

Regards.

like image 852
xavier.seignard Avatar asked Jan 10 '12 12:01

xavier.seignard


2 Answers

I've been searching for a way to do this as well, with not much success.

However, there is the following question which might provide some general hints:

Maven reporting plugins do not execute if a unit test failure occurs

The idea is that you would run mvn install (or whatever) first, and then run:

mvn -Dmaven.test.skip=true your-plugin:your-goal

This will let you run the build again without running tests, preserving the results for your perusal. Of course, this is only useful if your plugin is parsing the test results...

like image 121
hairyhenderson Avatar answered Oct 04 '22 22:10

hairyhenderson


Though not recommended, by setting the surefire property testFailureIgnore to true, you can continue maven execution even when there are test failures.

...
<plugin>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.11</version>
    ...
    <configuration>
        <testFailureIgnore>true</testFailureIgnore>
        ...
    </configuration>
</plugin>
...
like image 40
Raghuram Avatar answered Oct 04 '22 22:10

Raghuram