From 208eae24bd8068d90078362f57fe2246ba1b2107 Mon Sep 17 00:00:00 2001 From: Libor Rysavy Date: Tue, 11 Oct 2022 15:18:19 +0200 Subject: [PATCH] Sanitize failIfNoSpecifiedTests prefix in failsafe Surefire is using `surefire.failIfNoSpecifiedTests`, but failsafe used `it.failIfNoSpecifiedTests`. Error msg is then pointed to nonexistent property: `No tests matching pattern "..." were executed! (Set -Dfailsafe.failIfNoSpecifiedTests=false to ignore this error.)` --- .../plugin/failsafe/IntegrationTestMojo.java | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java index a670867048..b673b96b56 100644 --- a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java +++ b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java @@ -130,12 +130,24 @@ public class IntegrationTestMojo private boolean useFile; /** - * Set this to "true" to cause a failure if none of the tests specified in -Dtest=... are run. Defaults to + * Set this to "false" to prevent a failure if none of the tests specified in -Dit.test=... are run. Defaults to * "true". * * @since 2.12 + * @deprecated Since 3.0.0-M8, use "failsafe.failIfNoSpecifiedTests" instead. */ + @Deprecated @Parameter( property = "it.failIfNoSpecifiedTests", defaultValue = "true" ) + private boolean failIfNoSpecifiedTestsDeprecated; + + /** + * Set this to "false" to prevent a failure if none of the tests specified in -Dit.test=... are run. Defaults to + * "true". + * Replacing "it.failIfNoSpecifiedTests" to be consistent with surefire plugin. + * + * @since 3.0.0-M8 + */ + @Parameter( property = "failsafe.failIfNoSpecifiedTests", defaultValue = "true" ) private boolean failIfNoSpecifiedTests; /** @@ -899,9 +911,16 @@ public void setSystemPropertiesFile( File systemPropertiesFile ) } @Override + @SuppressWarnings( "deprecation" ) public boolean getFailIfNoSpecifiedTests() { - return failIfNoSpecifiedTests; + if ( !failIfNoSpecifiedTestsDeprecated ) + { + getConsoleLogger().warning( "Use " + getPluginName() + + ".failIfNoSpecifiedTests property instead of obsolete it.failIfNoSpecifiedTests." ); + } + // since both have default "true", assuming that any "false" is set by user on purpose + return failIfNoSpecifiedTests && failIfNoSpecifiedTestsDeprecated; } @Override