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/05/15 12:02:15 UTC

[maven-surefire] branch master updated: [SUREFIRE-1910] Missleading error message when using -Dtest=....

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 14bce33  [SUREFIRE-1910] Missleading error message when using -Dtest=....
14bce33 is described below

commit 14bce33c7a350d85df8db49f00cf650556d1131a
Author: tibordigana <ti...@gmail.com>
AuthorDate: Tue May 11 01:33:29 2021 +0200

    [SUREFIRE-1910] Missleading error message when using -Dtest=....
---
 .../maven/plugin/failsafe/IntegrationTestMojo.java |  6 +-
 .../apache/maven/plugin/failsafe/VerifyMojo.java   | 10 +--
 .../plugin/surefire/AbstractSurefireMojo.java      | 72 +++++++++++-----------
 .../surefire/SurefireExecutionParameters.java      |  2 +-
 .../maven/plugin/surefire/SurefireHelper.java      |  2 +-
 .../plugin/surefire/SurefireReportParameters.java  |  2 +-
 .../surefire/booterclient/BooterSerializer.java    |  3 -
 .../AbstractSurefireMojoJava7PlusTest.java         |  4 +-
 .../plugin/surefire/AbstractSurefireMojoTest.java  |  4 +-
 .../maven/plugin/surefire/MojoMocklessTest.java    |  4 +-
 ...ooterDeserializerProviderConfigurationTest.java |  5 +-
 ...BooterDeserializerStartupConfigurationTest.java |  4 +-
 .../maven/plugin/surefire/SurefirePlugin.java      |  6 +-
 .../api/testset/DirectoryScannerParameters.java    | 19 +-----
 .../maven/surefire/booter/BooterDeserializer.java  |  6 +-
 .../surefire/booter/ProviderConfiguration.java     | 10 +--
 .../maven/surefire/booter/SurefireReflector.java   |  3 +-
 .../surefire/booter/SurefireReflectorTest.java     |  4 +-
 .../maven/surefire/its/CheckSingleTestIT.java      |  2 +-
 19 files changed, 69 insertions(+), 99 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 a91139c..ee12c6b 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
@@ -135,8 +135,8 @@ public class IntegrationTestMojo
      *
      * @since 2.12
      */
-    @Parameter( property = "it.failIfNoSpecifiedTests" )
-    private Boolean failIfNoSpecifiedTests;
+    @Parameter( property = "it.failIfNoSpecifiedTests", defaultValue = "true" )
+    private boolean failIfNoSpecifiedTests;
 
     /**
      * Attach a debugger to the forked JVM. If set to "true", the process will suspend and wait for a debugger to attach
@@ -862,7 +862,7 @@ public class IntegrationTestMojo
     }
 
     @Override
-    public Boolean getFailIfNoSpecifiedTests()
+    public boolean getFailIfNoSpecifiedTests()
     {
         return failIfNoSpecifiedTests;
     }
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 52eacbe..b691741 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
@@ -132,12 +132,12 @@ public class VerifyMojo
     private File[] summaryFiles;
 
     /**
-     * Set this to "true" to cause a failure if there are no tests to run.
+     * Set this to "true" to cause a failure if there are no tests to run. Defaults to "false".
      *
      * @since 2.4
      */
-    @Parameter( property = "failIfNoTests" )
-    private Boolean failIfNoTests;
+    @Parameter( property = "failIfNoTests", defaultValue = "false" )
+    private boolean failIfNoTests;
 
     /**
      * Set this to a value greater than 0 to fail the whole test set if the cumulative number of flakes reaches
@@ -233,7 +233,7 @@ public class VerifyMojo
 
         if ( !getTestClassesDirectory().exists() )
         {
-            if ( getFailIfNoTests() != null && getFailIfNoTests() )
+            if ( getFailIfNoTests() )
             {
                 throw new MojoFailureException( "No tests to run!" );
             }
@@ -360,7 +360,7 @@ public class VerifyMojo
     }
 
     @Override
-    public Boolean getFailIfNoTests()
+    public boolean getFailIfNoTests()
     {
         return failIfNoTests;
     }
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
index 5109fde..f45f5d1 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
@@ -121,7 +121,6 @@ import java.util.TreeSet;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.zip.ZipFile;
 
-import static java.lang.Boolean.TRUE;
 import static java.lang.Integer.parseInt;
 import static java.lang.Thread.currentThread;
 import static java.util.Arrays.asList;
@@ -152,6 +151,9 @@ import static org.apache.maven.surefire.api.util.ReflectionUtils.invokeMethodWit
 import static org.apache.maven.surefire.api.util.ReflectionUtils.tryGetMethod;
 import static org.apache.maven.surefire.api.booter.ProviderParameterNames.INCLUDE_JUNIT5_ENGINES_PROP;
 import static org.apache.maven.surefire.api.booter.ProviderParameterNames.EXCLUDE_JUNIT5_ENGINES_PROP;
+import static org.apache.maven.plugin.surefire.AbstractSurefireMojo.PluginFailureReason.NONE;
+import static org.apache.maven.plugin.surefire.AbstractSurefireMojo.PluginFailureReason.COULD_NOT_RUN_SPECIFIED_TESTS;
+import static org.apache.maven.plugin.surefire.AbstractSurefireMojo.PluginFailureReason.COULD_NOT_RUN_DEFAULT_TESTS;
 
 /**
  * Abstract base class for running tests using Surefire.
@@ -383,8 +385,8 @@ public abstract class AbstractSurefireMojo
      *
      * @since 2.4
      */
-    @Parameter( property = "failIfNoTests" )
-    private Boolean failIfNoTests;
+    @Parameter( property = "failIfNoTests", defaultValue = "false" )
+    private boolean failIfNoTests;
 
     /**
      * <strong>DEPRECATED</strong> since version 2.14. Use {@code forkCount} and {@code reuseForks} instead.
@@ -927,13 +929,20 @@ public abstract class AbstractSurefireMojo
             DefaultScanResult scan = scanForTestClasses();
             if ( !hasSuiteXmlFiles() && scan.isEmpty() )
             {
-                if ( getEffectiveFailIfNoTests() )
+                switch ( getEffectiveFailIfNoTests() )
                 {
-                    throw new MojoFailureException(
-                        "No tests were executed!  (Set -DfailIfNoTests=false to ignore this error.)" );
+                    case COULD_NOT_RUN_DEFAULT_TESTS:
+                        throw new MojoFailureException(
+                            "No tests were executed!  (Set -DfailIfNoTests=false to ignore this error.)" );
+                    case COULD_NOT_RUN_SPECIFIED_TESTS:
+                        throw new MojoFailureException( "No tests matching pattern \""
+                            + getSpecificTests().toString()
+                            + "\" were executed! (Set "
+                            + "-D" + getPluginName() + ".failIfNoSpecifiedTests=false to ignore this error.)" );
+                    default:
+                        handleSummary( noTestsRun(), null );
+                        return;
                 }
-                handleSummary( noTestsRun(), null );
-                return;
             }
             logReportsDirectory();
             executeAfterPreconditionsChecked( scan, platform );
@@ -1115,7 +1124,7 @@ public abstract class AbstractSurefireMojo
         if ( !getTestClassesDirectory().exists()
             && ( getDependenciesToScan() == null || getDependenciesToScan().length == 0 ) )
         {
-            if ( TRUE.equals( getFailIfNoTests() ) )
+            if ( getFailIfNoTests() )
             {
                 throw new MojoFailureException( "No tests to run!" );
             }
@@ -1839,26 +1848,15 @@ public abstract class AbstractSurefireMojo
         return runOrders.contains( RunOrder.BALANCED ) || runOrders.contains( RunOrder.FAILEDFIRST );
     }
 
-    private boolean getEffectiveFailIfNoTests()
+    private PluginFailureReason getEffectiveFailIfNoTests()
     {
         if ( isSpecificTestSpecified() )
         {
-            if ( getFailIfNoSpecifiedTests() != null )
-            {
-                return getFailIfNoSpecifiedTests();
-            }
-            else if ( getFailIfNoTests() != null )
-            {
-                return getFailIfNoTests();
-            }
-            else
-            {
-                return true;
-            }
+            return getFailIfNoSpecifiedTests() ? COULD_NOT_RUN_SPECIFIED_TESTS : NONE;
         }
         else
         {
-            return getFailIfNoTests() != null && getFailIfNoTests();
+            return getFailIfNoTests() ? COULD_NOT_RUN_DEFAULT_TESTS : NONE;
         }
     }
 
@@ -1881,7 +1879,7 @@ public abstract class AbstractSurefireMojo
         DirectoryScannerParameters directoryScannerParameters = null;
         if ( hasSuiteXmlFiles() && !isSpecificTestSpecified() )
         {
-            actualFailIfNoTests = getFailIfNoTests() != null && getFailIfNoTests();
+            actualFailIfNoTests = getFailIfNoTests();
             if ( !isTestNg )
             {
                 throw new MojoExecutionException( "suiteXmlFiles is configured, but there is no TestNG dependency" );
@@ -1889,16 +1887,6 @@ public abstract class AbstractSurefireMojo
         }
         else
         {
-            if ( isSpecificTestSpecified() )
-            {
-                actualFailIfNoTests = getEffectiveFailIfNoTests();
-                setFailIfNoTests( actualFailIfNoTests );
-            }
-            else
-            {
-                actualFailIfNoTests = getFailIfNoTests() != null && getFailIfNoTests();
-            }
-
             // @todo remove these three params and use DirectoryScannerParameters to pass into DirectoryScanner only
             // @todo or remove it in next major version :: 3.0
             // @todo remove deprecated methods in ProviderParameters => included|excluded|specificTests not needed here
@@ -1910,12 +1898,12 @@ public abstract class AbstractSurefireMojo
 
             directoryScannerParameters =
                 new DirectoryScannerParameters( getTestClassesDirectory(), actualIncludes, actualExcludes,
-                                                specificTests, actualFailIfNoTests, getRunOrder() );
+                                                specificTests, getRunOrder() );
         }
 
         Map<String, String> providerProperties = toStringProperties( getProperties() );
 
-        return new ProviderConfiguration( directoryScannerParameters, runOrderParameters, actualFailIfNoTests,
+        return new ProviderConfiguration( directoryScannerParameters, runOrderParameters,
                                           reporterConfiguration,
                                           testNg, // Not really used in provider. Limited to de/serializer.
                                           testSuiteDefinition, providerProperties, null,
@@ -3742,7 +3730,7 @@ public abstract class AbstractSurefireMojo
     }
 
 
-    public Boolean getFailIfNoTests()
+    public boolean getFailIfNoTests()
     {
         return failIfNoTests;
     }
@@ -4215,4 +4203,14 @@ public abstract class AbstractSurefireMojo
             return classpath;
         }
     }
+
+    /**
+     * Determines whether the plugin should fail if no tests found to run.
+     */
+    enum PluginFailureReason
+    {
+        NONE,
+        COULD_NOT_RUN_SPECIFIED_TESTS,
+        COULD_NOT_RUN_DEFAULT_TESTS,
+    }
 }
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireExecutionParameters.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireExecutionParameters.java
index a570b82..2275b32 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireExecutionParameters.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireExecutionParameters.java
@@ -123,7 +123,7 @@ public interface SurefireExecutionParameters
 
     void setEncoding( String encoding );
 
-    Boolean getFailIfNoSpecifiedTests();
+    boolean getFailIfNoSpecifiedTests();
 
     void setFailIfNoSpecifiedTests( boolean failIfNoSpecifiedTests );
 
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireHelper.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireHelper.java
index d9a6918..d301ecc 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireHelper.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireHelper.java
@@ -253,7 +253,7 @@ public final class SurefireHelper
 
     private static boolean failIfNoTests( SurefireReportParameters reportParameters )
     {
-        return reportParameters.getFailIfNoTests() != null && reportParameters.getFailIfNoTests();
+        return reportParameters.getFailIfNoTests();
     }
 
     private static boolean isFatal( Exception firstForkException )
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireReportParameters.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireReportParameters.java
index 8b964e7..da808ed 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireReportParameters.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireReportParameters.java
@@ -56,7 +56,7 @@ public interface SurefireReportParameters
 
     void setReportsDirectory( File reportsDirectory );
 
-    Boolean getFailIfNoTests();
+    boolean getFailIfNoTests();
 
     void setFailIfNoTests( boolean failIfNoTests );
 
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java
index 1335a82..1385bd4 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java
@@ -47,7 +47,6 @@ import static org.apache.maven.surefire.booter.AbstractPathConfiguration.ENABLE_
 import static org.apache.maven.surefire.booter.AbstractPathConfiguration.SUREFIRE_CLASSPATH;
 import static org.apache.maven.surefire.booter.BooterConstants.EXCLUDES_PROPERTY_PREFIX;
 import static org.apache.maven.surefire.booter.BooterConstants.FAIL_FAST_COUNT;
-import static org.apache.maven.surefire.booter.BooterConstants.FAILIFNOTESTS;
 import static org.apache.maven.surefire.booter.BooterConstants.FORKTESTSET;
 import static org.apache.maven.surefire.booter.BooterConstants.FORKTESTSET_PREFER_TESTS_FROM_IN_STREAM;
 import static org.apache.maven.surefire.booter.BooterConstants.FORK_NUMBER;
@@ -151,7 +150,6 @@ class BooterSerializer
         DirectoryScannerParameters directoryScannerParameters = providerConfiguration.getDirScannerParams();
         if ( directoryScannerParameters != null )
         {
-            properties.setProperty( FAILIFNOTESTS, toString( directoryScannerParameters.isFailIfNoTests() ) );
             properties.addList( directoryScannerParameters.getIncludes(), INCLUDES_PROPERTY_PREFIX );
             properties.addList( directoryScannerParameters.getExcludes(), EXCLUDES_PROPERTY_PREFIX );
             properties.addList( directoryScannerParameters.getSpecificTests(), SPECIFIC_TEST_PROPERTY_PREFIX );
@@ -175,7 +173,6 @@ class BooterSerializer
         ClassLoaderConfiguration classLoaderConfig = startupConfiguration.getClassLoaderConfiguration();
         properties.setProperty( USESYSTEMCLASSLOADER, toString( classLoaderConfig.isUseSystemClassLoader() ) );
         properties.setProperty( USEMANIFESTONLYJAR, toString( classLoaderConfig.isUseManifestOnlyJar() ) );
-        properties.setProperty( FAILIFNOTESTS, toString( providerConfiguration.isFailIfNoTests() ) );
         properties.setProperty( PROVIDER_CONFIGURATION, startupConfiguration.getProviderClassName() );
         properties.setProperty( FAIL_FAST_COUNT, toString( providerConfiguration.getSkipAfterFailureCount() ) );
         properties.setProperty( SHUTDOWN, providerConfiguration.getShutdown().name() );
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoJava7PlusTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoJava7PlusTest.java
index f8a4c10..c1f8dc8 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoJava7PlusTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoJava7PlusTest.java
@@ -789,9 +789,9 @@ public class AbstractSurefireMojoJava7PlusTest
         }
 
         @Override
-        public Boolean getFailIfNoSpecifiedTests()
+        public boolean getFailIfNoSpecifiedTests()
         {
-            return null;
+            return false;
         }
 
         @Override
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoTest.java
index 45e35b7..da3bcfe 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoTest.java
@@ -2339,9 +2339,9 @@ public class AbstractSurefireMojoTest
         }
 
         @Override
-        public Boolean getFailIfNoSpecifiedTests()
+        public boolean getFailIfNoSpecifiedTests()
         {
-            return null;
+            return false;
         }
 
         @Override
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/MojoMocklessTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/MojoMocklessTest.java
index fe7a44a..c98cb75 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/MojoMocklessTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/MojoMocklessTest.java
@@ -638,9 +638,9 @@ public class MojoMocklessTest
         }
 
         @Override
-        public Boolean getFailIfNoSpecifiedTests()
+        public boolean getFailIfNoSpecifiedTests()
         {
-            return null;
+            return false;
         }
 
         @Override
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java
index 7a08390..55f63f3 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java
@@ -200,7 +200,6 @@ public class BooterDeserializerProviderConfigurationTest
         throws IOException
     {
         ProviderConfiguration reloaded = getReloadedProviderConfiguration();
-        assertTrue( reloaded.isFailIfNoTests() );
         assertEquals( cli, reloaded.getMainCliOptions() );
     }
 
@@ -238,7 +237,7 @@ public class BooterDeserializerProviderConfigurationTest
         excludes.add( "xx1" );
         excludes.add( "xx2" );
 
-        return new DirectoryScannerParameters( aDir, includes, excludes, Collections.<String>emptyList(), true,
+        return new DirectoryScannerParameters( aDir, includes, excludes, Collections.<String>emptyList(),
                                                RunOrder.asString( RunOrder.DEFAULT ) );
     }
 
@@ -277,7 +276,7 @@ public class BooterDeserializerProviderConfigurationTest
                              new TestListResolver( USER_REQUESTED_TEST + "#aUserRequestedTestMethod" ),
                     RERUN_FAILING_TEST_COUNT );
         RunOrderParameters runOrderParameters = new RunOrderParameters( RunOrder.DEFAULT, null );
-        return new ProviderConfiguration( directoryScannerParameters, runOrderParameters, true, reporterConfiguration,
+        return new ProviderConfiguration( directoryScannerParameters, runOrderParameters, reporterConfiguration,
                 new TestArtifactInfo( "5.0", "ABC" ), testSuiteDefinition, new HashMap<String, String>(), TEST_TYPED,
                 readTestsFromInStream, cli, 0, Shutdown.DEFAULT, 0 );
     }
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java
index 669e73c..9baf914 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java
@@ -191,14 +191,14 @@ public class BooterDeserializerStartupConfigurationTest
         File cwd = new File( "." );
         DirectoryScannerParameters directoryScannerParameters =
             new DirectoryScannerParameters( cwd, new ArrayList<String>(), new ArrayList<String>(),
-                                            new ArrayList<String>(), true, "hourly" );
+                                            new ArrayList<String>(), "hourly" );
         ReporterConfiguration reporterConfiguration = new ReporterConfiguration( cwd, true );
         TestRequest testSuiteDefinition =
             new TestRequest( Arrays.asList( getSuiteXmlFileStrings() ), getTestSourceDirectory(),
                              new TestListResolver( "aUserRequestedTest#aUserRequestedTestMethod" ) );
 
         RunOrderParameters runOrderParameters = new RunOrderParameters( RunOrder.DEFAULT, null );
-        return new ProviderConfiguration( directoryScannerParameters, runOrderParameters, true, reporterConfiguration,
+        return new ProviderConfiguration( directoryScannerParameters, runOrderParameters, reporterConfiguration,
                 new TestArtifactInfo( "5.0", "ABC" ), testSuiteDefinition, new HashMap<String, String>(),
                 BooterDeserializerProviderConfigurationTest.TEST_TYPED, true, cli, 0, Shutdown.DEFAULT, 0 );
     }
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 5f48cad..0e3d850 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
@@ -118,8 +118,8 @@ public class SurefirePlugin
      *
      * @since 2.12
      */
-    @Parameter( property = "surefire.failIfNoSpecifiedTests" )
-    private Boolean failIfNoSpecifiedTests;
+    @Parameter( property = "surefire.failIfNoSpecifiedTests", defaultValue = "true" )
+    private boolean failIfNoSpecifiedTests;
 
     /**
      * Attach a debugger to the forked JVM. If set to "true", the process will suspend and wait for a debugger to attach
@@ -685,7 +685,7 @@ public class SurefirePlugin
     }
 
     @Override
-    public Boolean getFailIfNoSpecifiedTests()
+    public boolean getFailIfNoSpecifiedTests()
     {
         return failIfNoSpecifiedTests;
     }
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/api/testset/DirectoryScannerParameters.java b/surefire-api/src/main/java/org/apache/maven/surefire/api/testset/DirectoryScannerParameters.java
index c407edb..4c1eae2 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/api/testset/DirectoryScannerParameters.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/api/testset/DirectoryScannerParameters.java
@@ -39,26 +39,23 @@ public class DirectoryScannerParameters
     @Deprecated
     private final List<String> specificTests;
 
-    private final boolean failIfNoTests;
-
     private final RunOrder[] runOrder;
 
     private DirectoryScannerParameters( File testClassesDirectory, List<String> includes, List<String> excludes,
-                                        List<String> specificTests, boolean failIfNoTests, RunOrder[] runOrder )
+                                        List<String> specificTests, RunOrder[] runOrder )
     {
         this.testClassesDirectory = testClassesDirectory;
         this.includes = includes;
         this.excludes = excludes;
         this.specificTests = specificTests;
-        this.failIfNoTests = failIfNoTests;
         this.runOrder = runOrder;
     }
 
     public DirectoryScannerParameters( File testClassesDirectory, @Deprecated List<String> includes,
                                        @Deprecated List<String> excludes, @Deprecated List<String> specificTests,
-                                       boolean failIfNoTests, String runOrder )
+                                       String runOrder )
     {
-        this( testClassesDirectory, includes, excludes, specificTests, failIfNoTests,
+        this( testClassesDirectory, includes, excludes, specificTests,
               runOrder == null ? RunOrder.DEFAULT : RunOrder.valueOfMulti( runOrder ) );
     }
 
@@ -100,16 +97,6 @@ public class DirectoryScannerParameters
         return excludes;
     }
 
-    /**
-     * Indicates if lack of runable tests should fail the entire build
-     *
-     * @return true if no tests should fail the build
-     */
-    public boolean isFailIfNoTests()
-    {
-        return failIfNoTests;
-    }
-
     public RunOrder[] getRunOrder()
     {
         return runOrder;
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java
index ca5328e..2b365ad 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java
@@ -113,8 +113,7 @@ public class BooterDeserializer
         final int rerunFailingTestsCount = properties.getIntProperty( RERUN_FAILING_TESTS_COUNT );
 
         DirectoryScannerParameters dirScannerParams =
-            new DirectoryScannerParameters( testClassesDirectory, includes, excludes, specificTests,
-                                            properties.getBooleanProperty( FAILIFNOTESTS ), runOrder );
+            new DirectoryScannerParameters( testClassesDirectory, includes, excludes, specificTests, runOrder );
 
         RunOrderParameters runOrderParameters
                 = new RunOrderParameters( runOrder, runStatisticsFile == null ? null : new File( runStatisticsFile ),
@@ -138,8 +137,7 @@ public class BooterDeserializer
         Integer systemExitTimeout =
                 systemExitTimeoutAsString == null ? null : Integer.valueOf( systemExitTimeoutAsString );
 
-        return new ProviderConfiguration( dirScannerParams, runOrderParameters,
-                                          properties.getBooleanProperty( FAILIFNOTESTS ), reporterConfiguration, testNg,
+        return new ProviderConfiguration( dirScannerParams, runOrderParameters, reporterConfiguration, testNg,
                                           testSuiteDefinition, properties.getProperties(), typeEncodedTestForFork,
                                           preferTestsFromInStream, fromStrings( cli ), failFastCount, shutdown,
                                           systemExitTimeout );
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderConfiguration.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderConfiguration.java
index 54b6187..fd0effc 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderConfiguration.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderConfiguration.java
@@ -54,8 +54,6 @@ public class ProviderConfiguration
 
     private final Map<String, String> providerProperties;
 
-    private final boolean failIfNoTests;
-
     private final TypeEncodedValue forkTestSet;
 
     private final boolean readTestsFromInStream;
@@ -70,7 +68,7 @@ public class ProviderConfiguration
 
     @SuppressWarnings( "checkstyle:parameternumber" )
     public ProviderConfiguration( DirectoryScannerParameters directoryScannerParameters,
-                                  RunOrderParameters runOrderParameters, boolean failIfNoTests,
+                                  RunOrderParameters runOrderParameters,
                                   ReporterConfiguration reporterConfiguration, TestArtifactInfo testArtifact,
                                   TestRequest testSuiteDefinition, Map<String, String> providerProperties,
                                   TypeEncodedValue typeEncodedTestSet, boolean readTestsFromInStream,
@@ -83,7 +81,6 @@ public class ProviderConfiguration
         this.testArtifact = testArtifact;
         this.testSuiteDefinition = testSuiteDefinition;
         this.dirScannerParams = directoryScannerParameters;
-        this.failIfNoTests = failIfNoTests;
         this.forkTestSet = typeEncodedTestSet;
         this.readTestsFromInStream = readTestsFromInStream;
         this.mainCliOptions = mainCliOptions;
@@ -97,11 +94,6 @@ public class ProviderConfiguration
         return reporterConfiguration;
     }
 
-    public boolean isFailIfNoTests()
-    {
-        return failIfNoTests;
-    }
-
     public File getBaseDir()
     {
         return dirScannerParams.getTestClassesDirectory();
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java
index d4f459a..2df77b0 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java
@@ -160,14 +160,13 @@ public final class SurefireReflector
             return null;
         }
         //Can't use the constructor with the RunOrder parameter. Using it causes some integration tests to fail.
-        Class<?>[] arguments = { File.class, List.class, List.class, List.class, boolean.class, String.class };
+        Class<?>[] arguments = { File.class, List.class, List.class, List.class, String.class };
         Constructor<?> constructor = getConstructor( this.directoryScannerParameters, arguments );
         return newInstance( constructor,
                             directoryScannerParameters.getTestClassesDirectory(),
                             directoryScannerParameters.getIncludes(),
                             directoryScannerParameters.getExcludes(),
                             directoryScannerParameters.getSpecificTests(),
-                            directoryScannerParameters.isFailIfNoTests(),
                             RunOrder.asString( directoryScannerParameters.getRunOrder() ) );
     }
 
diff --git a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java
index 88fd583..b4290a7 100644
--- a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java
+++ b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java
@@ -81,7 +81,7 @@ public class SurefireReflectorTest
 
         DirectoryScannerParameters directoryScannerParameters =
                 new DirectoryScannerParameters( new File( "ABC" ), new ArrayList<String>(), new ArrayList<String>(),
-                        new ArrayList<String>(), false, "hourly" );
+                        new ArrayList<String>(), "hourly" );
         surefireReflector.setDirectoryScannerParameters( foo, directoryScannerParameters );
         assertTrue( isCalled( foo ) );
         assertNotNull( ( (Foo) foo ).getDirectoryScannerParameters() );
@@ -104,7 +104,7 @@ public class SurefireReflectorTest
 
         DirectoryScannerParameters directoryScannerParameters =
             new DirectoryScannerParameters( new File( "ABC" ), new ArrayList<String>(), new ArrayList<String>(),
-                new ArrayList<String>(), false, "hourly" );
+                new ArrayList<String>(), "hourly" );
         surefireReflector.setIfDirScannerAware( foo, directoryScannerParameters );
         assertTrue( isCalled( foo ) );
     }
diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckSingleTestIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckSingleTestIT.java
index 95bbc35..343d3b3 100644
--- a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckSingleTestIT.java
+++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckSingleTestIT.java
@@ -60,7 +60,7 @@ public class CheckSingleTestIT
     public void singleTestNonExistentOverride()
     {
         final OutputValidator output =
-            unpack().setTestToRun( "DoesNotExist" ).failIfNoTests( false ).executeTest().verifyErrorFreeLog();
+            unpack().setTestToRun( "DoesNotExist" ).failIfNoSpecifiedTests( false ).executeTest().verifyErrorFreeLog();
         output.getTargetFile( "surefire-reports" );
         //   assertFalse( "Unexpected reports directory", reportsDir.exists() ); Hmpf. Not really a good test
     }