| ------ |
| Skipping Tests After Failure |
| ------ |
| Tibor Digana |
| ------ |
| July 2015 |
| ------ |
| |
| ~~ Licensed to the Apache Software Foundation (ASF) under one |
| ~~ or more contributor license agreements. See the NOTICE file |
| ~~ distributed with this work for additional information |
| ~~ regarding copyright ownership. The ASF licenses this file |
| ~~ to you under the Apache License, Version 2.0 (the |
| ~~ "License"); you may not use this file except in compliance |
| ~~ with the License. You may obtain a copy of the License at |
| ~~ |
| ~~ http://www.apache.org/licenses/LICENSE-2.0 |
| ~~ |
| ~~ Unless required by applicable law or agreed to in writing, |
| ~~ software distributed under the License is distributed on an |
| ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| ~~ KIND, either express or implied. See the License for the |
| ~~ specific language governing permissions and limitations |
| ~~ under the License. |
| |
| ~~ NOTE: For help with the syntax of this file, see: |
| ~~ http://maven.apache.org/doxia/references/apt-format.html |
| |
| 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 ${project.artifactId} 2.19 or higher, JUnit 4.0 or higher, or |
| TestNG 5.10 or higher, JUnit5 5.4.0 or higher. |
| |
| If version of TestNG is lower 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 lower 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. |
| |
| Other features |
| |
| * Re-run and skip execution |
| |
| Since of 2.19.1 you can use parameters <<<skipAfterFailureCount>>> and <<<rerunFailingTestsCount>>> together. |
| This is enabled by providers <<<surefire-junit4>>> and <<<surefire-junit47>>>. You can run again failed tests |
| and skip the rest of the test-set if errors or failures reached <<<skipAfterFailureCount>>>. |
| Notice that failed tests within re-run phase are not included in <<<skipAfterFailureCount>>>. |