Fork me on GitHub

Skipping Tests After First Failure

To skip remaining tests after first failure or error has happened set configuration parameter skipAfterFailureCount to 1.

Skipping Tests After the Nth Failure or Error

To skip remaining tests after the Nth failure or error has happened set configuration parameter skipAfterFailureCount to N, where N is number greater than zero.

Prerequisite

Use maven-surefire-plugin 2.19 or higher, JUnit 4.0 or higher, or TestNG 5.10 or higher.

If version of TestNG is lover than 5.10 while the parameter skipAfterFailureCount is set, the plugin fails with error:

[ERROR] Failed to execute goal ...: Parameter "skipAfterFailureCount" expects TestNG Version 5.10 or higher. java.lang.NoClassDefFoundError: org/testng/IInvokedMethodListener

If version of JUnit is lover than 4.0 while the parameter skipAfterFailureCount is set, the plugin fails with error:

[ERROR] Failed to execute goal ...: Parameter "skipAfterFailureCount" expects JUnit Version 4.0 or higher. java.lang.NoSuchMethodError: org.junit.runner.notification.RunNotifier.pleaseStop()V

Notices

TestNG reports skipped methods however JUnit reports skipped classes. Preferably use JUnit 4.12 or higher version which fixed thread safety issues.

Limitations

Although this feature works in forking modes as well, the functionality cannot be fully guaranteed (real first failure) in concurrent mode due to race conditions. The parameter reuseForks should be always set to true (which is default value), otherwise this feature won't work properly in most cases.