You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ti...@apache.org on 2021/03/02 23:26:15 UTC
[maven-surefire] branch master updated: Add more documentation and
verification for failOnFlakeCount
This is an automated email from the ASF dual-hosted git repository.
tibordigana pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git
The following commit(s) were added to refs/heads/master by this push:
new 140f91d Add more documentation and verification for failOnFlakeCount
140f91d is described below
commit 140f91df6e3171cdec2c7246394ab60255a374be
Author: Stefan Oehme <st...@gmail.com>
AuthorDate: Tue Feb 16 12:48:05 2021 +0100
Add more documentation and verification for failOnFlakeCount
---
.../main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java | 2 ++
.../java/org/apache/maven/plugin/surefire/SurefirePlugin.java | 6 ++++++
.../src/site/apt/examples/rerun-failing-tests.apt.vm | 6 ++++++
.../org/apache/maven/plugin/surefire/SurefirePluginTest.java | 10 +++++++++-
4 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java
index b9309a3..52eacbe 100644
--- a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java
+++ b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java
@@ -142,6 +142,8 @@ public class VerifyMojo
/**
* Set this to a value greater than 0 to fail the whole test set if the cumulative number of flakes reaches
* this threshold. Set to 0 to allow an unlimited number of flakes.
+ *
+ * @since 3.0.0-M6
*/
@Parameter( property = "failsafe.failOnFlakeCount", defaultValue = "0" )
private int failOnFlakeCount;
diff --git a/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java b/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
index 5126a62..16ffaf9 100644
--- a/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
+++ b/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
@@ -257,6 +257,8 @@ public class SurefirePlugin
/**
* Set this to a value greater than 0 to fail the whole test set if the cumulative number of flakes reaches
* this threshold. Set to 0 to allow an unlimited number of flakes.
+ *
+ * @since 3.0.0-M6
*/
@Parameter( property = "surefire.failOnFlakeCount", defaultValue = "0" )
private int failOnFlakeCount;
@@ -908,6 +910,10 @@ public class SurefirePlugin
{
throw new MojoFailureException( "Parameter \"failOnFlakeCount\" should not be negative." );
}
+ if ( failOnFlakeCount > 0 && rerunFailingTestsCount < 1 )
+ {
+ throw new MojoFailureException( "\"failOnFlakeCount\" requires rerunFailingTestsCount to be at least 1." );
+ }
}
@Override
diff --git a/maven-surefire-plugin/src/site/apt/examples/rerun-failing-tests.apt.vm b/maven-surefire-plugin/src/site/apt/examples/rerun-failing-tests.apt.vm
index 9b5fc63..8214f84 100644
--- a/maven-surefire-plugin/src/site/apt/examples/rerun-failing-tests.apt.vm
+++ b/maven-surefire-plugin/src/site/apt/examples/rerun-failing-tests.apt.vm
@@ -154,3 +154,9 @@ mvn -D${thisPlugin.toLowerCase()}.rerunFailingTestsCount=2 test
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>>>.
+
+* Re-run and fail the build upon flaky test count
+
+ Since 3.0.0-M6 you can use <<<rerunFailingTestsCount>>> together with <<<failOnFlakeCount>>>.
+ This will fail the build if more than the specified number of tests are flaky, i.e. if they
+ had a successful run after previously failing.
diff --git a/maven-surefire-plugin/src/test/java/org/apache/maven/plugin/surefire/SurefirePluginTest.java b/maven-surefire-plugin/src/test/java/org/apache/maven/plugin/surefire/SurefirePluginTest.java
index e4297f4..2da402a 100644
--- a/maven-surefire-plugin/src/test/java/org/apache/maven/plugin/surefire/SurefirePluginTest.java
+++ b/maven-surefire-plugin/src/test/java/org/apache/maven/plugin/surefire/SurefirePluginTest.java
@@ -120,11 +120,19 @@ public class SurefirePluginTest extends TestCase
.isEqualTo( new File( "testShouldGetPropertyFile" ) );
}
- public void testFailOnFlakeCountVerification()
+ public void testNegativeFailOnFlakeCount()
{
SurefirePlugin plugin = new SurefirePlugin();
plugin.setFailOnFlakeCount( -1 );
e.expect( MojoFailureException.class );
e.expectMessage( "Parameter \"failOnFlakeCount\" should not be negative." );
}
+
+ public void testFailOnFlakeCountWithoutRerun()
+ {
+ SurefirePlugin plugin = new SurefirePlugin();
+ plugin.setFailOnFlakeCount( 1 );
+ e.expect( MojoFailureException.class );
+ e.expectMessage( "\"failOnFlakeCount\" requires rerunFailingTestsCount to be at least 1." );
+ }
}