xavier.seignard
xavier.seignard

Reputation: 11144

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.

Upvotes: 9

Views: 19510

Answers (6)

Muhammed Shoaib A
Muhammed Shoaib A

Reputation: 1

After adding this below plugin, I think what we have done here is we have ignored the test cases. I dont think this is the right solution for it, please provide any optimistic solution.

           <groupId>org.apache.maven.plugins</groupId>
           <artifactId>maven-surefire-plugin</artifactId>
           <version>2.19.1</version>
           <configuration>
           <testFailureIgnore>true</testFailureIgnore>
        </configuration>

       </plugin>

Upvotes: 0

Sachindra N. Pandey
Sachindra N. Pandey

Reputation: 1252

I added this plugin in pom.xml and it worked well.

            <plugin>

               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-surefire-plugin</artifactId>
               <version>2.19.1</version>
               <configuration>
               <testFailureIgnore>true</testFailureIgnore>
            </configuration>

           </plugin>

Upvotes: 1

ParisaN
ParisaN

Reputation: 2092

Just do mvn clean install -DskipTests

Upvotes: 5

hairyhenderson
hairyhenderson

Reputation: 587

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...

Upvotes: 5

Pete
Pete

Reputation: 10918

If you want to the build to run KNOWING beforehand that there are going to be failures, you can use:

mvn <goal> -Dmaven.test.skip = true

Upvotes: 0

Raghuram
Raghuram

Reputation: 52645

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>
...

Upvotes: 4

Related Questions