Stop Tests on first Failure with Maven/JUnit/Spring Stop Tests on first Failure with Maven/JUnit/Spring jenkins jenkins

Stop Tests on first Failure with Maven/JUnit/Spring


This is more a remark, than an answer, but still, maybe you'll find it useful.

I'd recommend separating your integration tests into a separate phase, and running them with Failsafe, rather than Surefire. This way you can decide whether you need to run only fast unit tests, or the complete set with long-running integration tests:

    <plugins>        <plugin>            <groupId>org.apache.maven.plugins</groupId>            <artifactId>maven-failsafe-plugin</artifactId>            <version>2.6</version>            <executions>                <execution>                    <id>integration-test</id>                    <goals>                        <goal>integration-test</goal>                    </goals>                </execution>                <!-- Uncomment/comment this in order to fail the build if any integration test fail -->                <execution>                    <id>verify</id>                    <goals><goal>verify</goal></goals>                  </execution>            </executions>        </plugin>    </plugins>

A workaround for your problem might be singling out a test into a separate execution and run it first; this way the execution would fail and subsequent surefire/failsafe executions will not be launched. See how to configure the plugin to do it.