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 2015/12/26 02:23:36 UTC

[1/4] maven-surefire git commit: [SUREFIRE] refactoring

Repository: maven-surefire
Updated Branches:
  refs/heads/master d891907a7 -> 7f64ddbf2


[SUREFIRE] refactoring


Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/b8257553
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/b8257553
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/b8257553

Branch: refs/heads/master
Commit: b8257553bcbc4e8c3c1da72aabce4db3b10ea690
Parents: fd3ed68
Author: Tibor17 <ti...@lycos.com>
Authored: Sun Dec 20 01:34:02 2015 +0100
Committer: Tibor17 <ti...@lycos.com>
Committed: Sat Dec 26 02:22:48 2015 +0100

----------------------------------------------------------------------
 .../java/org/apache/maven/surefire/util/TestsToRun.java   | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/b8257553/surefire-api/src/main/java/org/apache/maven/surefire/util/TestsToRun.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/TestsToRun.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/TestsToRun.java
index a8982d4..3b5ef22 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/util/TestsToRun.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/TestsToRun.java
@@ -129,15 +129,15 @@ public class TestsToRun implements Iterable<Class<?>>
 
     public String toString()
     {
-        StringBuilder sb = new StringBuilder();
-        sb.append( "TestsToRun: [" );
+        String sb = "TestsToRun: [";
         for ( Class<?> clazz : this )
         {
-            sb.append( " " ).append( clazz.getName() );
+            sb += " ";
+            sb += clazz.getName();
         }
 
-        sb.append( ']' );
-        return sb.toString();
+        sb += ']';
+        return sb;
     }
 
     public boolean containsAtLeast( int atLeast )


[3/4] maven-surefire git commit: [SUREFIRE] refactoring

Posted by ti...@apache.org.
[SUREFIRE] refactoring


Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/6e3be85d
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/6e3be85d
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/6e3be85d

Branch: refs/heads/master
Commit: 6e3be85d1dbbd3d0412ab44f72fdfb5ce134f5ce
Parents: b825755
Author: Tibor17 <ti...@lycos.com>
Authored: Sun Dec 20 01:46:09 2015 +0100
Committer: Tibor17 <ti...@lycos.com>
Committed: Sat Dec 26 02:22:49 2015 +0100

----------------------------------------------------------------------
 .../org/apache/maven/surefire/util/RunOrder.java | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/6e3be85d/surefire-api/src/main/java/org/apache/maven/surefire/util/RunOrder.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/RunOrder.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/RunOrder.java
index e262e53..4647172 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/util/RunOrder.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/RunOrder.java
@@ -83,27 +83,26 @@ public class RunOrder
                 }
             }
 
-            StringBuffer errorMessage = createMessageForMissingRunOrder( name );
-            throw new IllegalArgumentException( errorMessage.toString() );
+            String errorMessage = createMessageForMissingRunOrder( name );
+            throw new IllegalArgumentException( errorMessage );
         }
     }
 
-    private static StringBuffer createMessageForMissingRunOrder( String name )
+    private static String createMessageForMissingRunOrder( String name )
     {
         RunOrder[] runOrders = values();
-        StringBuffer message = new StringBuffer();
-        message.append( "There's no RunOrder with the name " );
-        message.append( name );
-        message.append( ". Please use one of the following RunOrders: " );
+        String message = "There's no RunOrder with the name ";
+        message += name;
+        message += ". Please use one of the following RunOrders: ";
         for ( int i = 0; i < runOrders.length; i++ )
         {
             if ( i != 0 )
             {
-                message.append( ", " );
+                message += ", ";
             }
-            message.append( runOrders[i] );
+            message += runOrders[i];
         }
-        message.append( "." );
+        message += ".";
         return message;
     }
 


[2/4] maven-surefire git commit: [SUREFIRE-1209] added surefire-junit4 support

Posted by ti...@apache.org.
[SUREFIRE-1209] added surefire-junit4 support


Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/fd3ed68a
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/fd3ed68a
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/fd3ed68a

Branch: refs/heads/master
Commit: fd3ed68a155d83e96c0d63764a24da1bb46c95a9
Parents: d891907
Author: Tibor17 <ti...@lycos.com>
Authored: Sat Dec 19 22:21:04 2015 +0100
Committer: Tibor17 <ti...@lycos.com>
Committed: Sat Dec 26 02:22:48 2015 +0100

----------------------------------------------------------------------
 .../jiras/Surefire1209RerunAndForkCountIT.java  |  2 +-
 .../surefire-1209-rerun-and-forkcount/pom.xml   | 71 +++++++++++++++-----
 2 files changed, 56 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/fd3ed68a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1209RerunAndForkCountIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1209RerunAndForkCountIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1209RerunAndForkCountIT.java
index 90108d1..a6cb73d 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1209RerunAndForkCountIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1209RerunAndForkCountIT.java
@@ -1 +1 @@
-package org.apache.maven.surefire.its.jiras;

/*
 * 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.
 */

import org.apache.maven.it.VerificationException;
import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
import org
 .apache.maven.surefire.its.fixture.SurefireLauncher;
import org.junit.Test;

/**
 * @author <a href="mailto:tibordigana@apache.org">Tibor Digana (tibor17)</a>
 * @see {@linkplain https://jira.codehaus.org/browse/SUREFIRE-1209}
 * @since 2.19
 */
public class Surefire1209RerunAndForkCountIT
        extends SurefireJUnit4IntegrationTestCase
{
    @Test
    public void reusableForks()
            throws VerificationException
    {
        unpack().executeTest()
                .assertTestSuiteResults( 5, 0, 0, 0, 4 );
    }

    @Test
    public void notReusableForks()
            throws VerificationException
    {
        unpack().reuseForks( false )
                .executeTest()
                .assertTestSuiteResults( 5, 0, 0, 0, 4 );
    }

    private SurefireLauncher unpack()
    {
        return unpack( "surefire-1209-rerun-and-forkcount" );
    }
}
\ No newline at end of file
+package org.apache.maven.surefire.its.jiras;

/*
 * 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.
 */

import org.apache.maven.it.VerificationException;
import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
import org
 .apache.maven.surefire.its.fixture.SurefireLauncher;
import org.junit.Test;

/**
 * @author <a href="mailto:tibordigana@apache.org">Tibor Digana (tibor17)</a>
 * @see {@linkplain https://jira.codehaus.org/browse/SUREFIRE-1209}
 * @since 2.19
 */
public class Surefire1209RerunAndForkCountIT
        extends SurefireJUnit4IntegrationTestCase
{
    @Test
    public void reusableForksJUnit47()
            throws VerificationException
    {
        unpack().executeTest()
                .assertTestSuiteResults( 5, 0, 0, 0, 4 );
    }

    @Test
    public void notReusableForksJUnit47()
            throws VerificationException
    {
        unpack().reuseForks( false )
                .executeTest()
                .assertTestSuiteResults( 5, 0, 0, 0, 4 );
    }

    @Test
    public void reusableForksJUnit4()
            throws VerificationException
    {
        unpack().addGoal( "-Pjunit4" )
                .executeTest()
                .assertTestSuiteResults( 5, 0, 0, 0, 4 );
    }
     @Test
    public void notReusableForksJUnit4()
            throws VerificationException
    {
        unpack().addGoal( "-Pjunit4" )
                .reuseForks( false )
                .executeTest()
                .assertTestSuiteResults( 5, 0, 0, 0, 4 );
    }

    private SurefireLauncher unpack()
    {
        return unpack( "surefire-1209-rerun-and-forkcount" );
    }
}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/fd3ed68a/surefire-integration-tests/src/test/resources/surefire-1209-rerun-and-forkcount/pom.xml
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/surefire-1209-rerun-and-forkcount/pom.xml b/surefire-integration-tests/src/test/resources/surefire-1209-rerun-and-forkcount/pom.xml
index 2e10ed5..15fe206 100644
--- a/surefire-integration-tests/src/test/resources/surefire-1209-rerun-and-forkcount/pom.xml
+++ b/surefire-integration-tests/src/test/resources/surefire-1209-rerun-and-forkcount/pom.xml
@@ -59,23 +59,62 @@
                     <target>1.5</target>
                 </configuration>
             </plugin>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-surefire-plugin</artifactId>
-                <version>${surefire.version}</version>
-                <configuration>
-                    <forkCount>2</forkCount>
-                    <rerunFailingTestsCount>3</rerunFailingTestsCount>
-                </configuration>
-                <dependencies>
-                    <dependency>
-                        <groupId>org.apache.maven.surefire</groupId>
-                        <artifactId>surefire-junit47</artifactId>
-                        <version>${surefire.version}</version>
-                    </dependency>
-                </dependencies>
-            </plugin>
         </plugins>
+        <pluginManagement>
+            <plugins>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-surefire-plugin</artifactId>
+                    <version>${surefire.version}</version>
+                    <configuration>
+                        <forkCount>2</forkCount>
+                        <rerunFailingTestsCount>3</rerunFailingTestsCount>
+                    </configuration>
+                </plugin>
+            </plugins>
+        </pluginManagement>
     </build>
 
+    <profiles>
+        <profile>
+            <id>junit47</id>
+            <activation>
+                <activeByDefault>true</activeByDefault>
+            </activation>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-surefire-plugin</artifactId>
+                        <dependencies>
+                            <dependency>
+                                <groupId>org.apache.maven.surefire</groupId>
+                                <artifactId>surefire-junit47</artifactId>
+                                <version>${surefire.version}</version>
+                            </dependency>
+                        </dependencies>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+        <profile>
+            <id>junit4</id>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-surefire-plugin</artifactId>
+                        <dependencies>
+                            <dependency>
+                                <groupId>org.apache.maven.surefire</groupId>
+                                <artifactId>surefire-junit4</artifactId>
+                                <version>${surefire.version}</version>
+                            </dependency>
+                        </dependencies>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
+
 </project>
\ No newline at end of file


[4/4] maven-surefire git commit: [SUREFIRE-1202] Allow rerunFailingTestsCount, skipAfterFailureCount together

Posted by ti...@apache.org.
[SUREFIRE-1202] Allow rerunFailingTestsCount, skipAfterFailureCount together


Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/7f64ddbf
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/7f64ddbf
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/7f64ddbf

Branch: refs/heads/master
Commit: 7f64ddbf208e47656fea57423822387bd9c13451
Parents: 6e3be85
Author: Tibor17 <ti...@lycos.com>
Authored: Sat Dec 26 02:22:36 2015 +0100
Committer: Tibor17 <ti...@lycos.com>
Committed: Sat Dec 26 02:22:50 2015 +0100

----------------------------------------------------------------------
 .../plugin/surefire/AbstractSurefireMojo.java   |   8 --
 .../apt/examples/rerun-failing-tests.apt.vm     |   8 ++
 .../site/apt/examples/skip-after-failure.apt.vm |  10 +-
 .../its/jiras/Surefire1202RerunAndSkipIT.java   |  58 +++++++++
 .../surefire-1202-rerun-and-failfast/pom.xml    | 122 +++++++++++++++++++
 .../src/test/java/pkg/ATest.java                |  45 +++++++
 .../src/test/java/pkg/BTest.java                |  42 +++++++
 .../src/test/java/pkg/CTest.java                |  35 ++++++
 .../src/test/java/pkg/DTest.java                |  35 ++++++
 .../src/test/java/pkg/ETest.java                |  31 +++++
 .../maven/surefire/common/junit4/Notifier.java  |  79 ++++++++----
 .../maven/surefire/junit4/JUnit4Provider.java   |  15 ++-
 .../surefire/junitcore/JUnitCoreProvider.java   |  17 +--
 .../surefire/junitcore/JUnitCoreWrapper.java    |  20 +--
 .../surefire/junitcore/Surefire746Test.java     |   2 +-
 15 files changed, 463 insertions(+), 64 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7f64ddbf/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
----------------------------------------------------------------------
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 f169446..2654e2e 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
@@ -2396,14 +2396,6 @@ public abstract class AbstractSurefireMojo
         {
             throw new MojoFailureException( "Parameter \"skipAfterFailureCount\" should not be negative." );
         }
-
-        boolean isRerun = getRerunFailingTestsCount() > 0;
-        boolean isFailFast = getSkipAfterFailureCount() > 0;
-        if ( isRerun && isFailFast )
-        {
-            throw new MojoFailureException( "Parameters [\"rerunFailingTestsCount\", \"skipAfterFailureCount\"] "
-                                                + "should not be enabled together." );
-        }
     }
 
     private void warnIfWrongShutdownValue()

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7f64ddbf/maven-surefire-plugin/src/site/apt/examples/rerun-failing-tests.apt.vm
----------------------------------------------------------------------
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 effd7b4..8a6a8bd 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
@@ -139,3 +139,11 @@ mvn -D${thisPlugin.toLowerCase()}.rerunFailingTestsCount=2 test
 
   The provider <<<surefire-junit4>>> executes individual test class and consequently re-runs failed tests.
   The provider <<<surefire-junit47>>> executes all test classes and re-runs failed tests afterwards.
+
+* 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>>>.
+

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7f64ddbf/maven-surefire-plugin/src/site/apt/examples/skip-after-failure.apt.vm
----------------------------------------------------------------------
diff --git a/maven-surefire-plugin/src/site/apt/examples/skip-after-failure.apt.vm b/maven-surefire-plugin/src/site/apt/examples/skip-after-failure.apt.vm
index 1ba41bd..06ed150 100644
--- a/maven-surefire-plugin/src/site/apt/examples/skip-after-failure.apt.vm
+++ b/maven-surefire-plugin/src/site/apt/examples/skip-after-failure.apt.vm
@@ -74,4 +74,12 @@ Limitations
  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.
- 
\ No newline at end of file
+
+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>>>.

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7f64ddbf/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1202RerunAndSkipIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1202RerunAndSkipIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1202RerunAndSkipIT.java
new file mode 100644
index 0000000..7d60138
--- /dev/null
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1202RerunAndSkipIT.java
@@ -0,0 +1,58 @@
+package org.apache.maven.surefire.its.jiras;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.it.VerificationException;
+import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
+import org.apache.maven.surefire.its.fixture.SurefireLauncher;
+import org.junit.Test;
+
+/**
+ * Allow rerunFailingTestsCount, skipAfterFailureCount together
+ *
+ * @author <a href="mailto:tibordigana@apache.org">Tibor Digana (tibor17)</a>
+ * @see {@linkplain https://jira.codehaus.org/browse/SUREFIRE-1202}
+ * @since 2.19.1
+ */
+public class Surefire1202RerunAndSkipIT
+        extends SurefireJUnit4IntegrationTestCase
+{
+    @Test
+    public void junit47()
+            throws VerificationException
+    {
+        unpack().executeTest()
+                .assertTestSuiteResults( 5, 0, 0, 3, 4 );
+    }
+
+    @Test
+    public void junit4()
+            throws VerificationException
+    {
+        unpack().addGoal( "-Pjunit4" )
+                .executeTest()
+                .assertTestSuiteResults( 5, 0, 0, 3, 4 );
+    }
+
+    private SurefireLauncher unpack()
+    {
+        return unpack( "surefire-1202-rerun-and-failfast" );
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7f64ddbf/surefire-integration-tests/src/test/resources/surefire-1202-rerun-and-failfast/pom.xml
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/surefire-1202-rerun-and-failfast/pom.xml b/surefire-integration-tests/src/test/resources/surefire-1202-rerun-and-failfast/pom.xml
new file mode 100644
index 0000000..2ba6100
--- /dev/null
+++ b/surefire-integration-tests/src/test/resources/surefire-1202-rerun-and-failfast/pom.xml
@@ -0,0 +1,122 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>org.apache.maven.plugins.surefire</groupId>
+    <artifactId>jiras-surefire-1202</artifactId>
+    <version>1.0</version>
+
+    <url>http://maven.apache.org</url>
+
+    <developers>
+        <developer>
+            <id>tibordigana</id>
+            <name>Tibor Digaňa (tibor17)</name>
+            <email>tibordigana@apache.org</email>
+            <roles>
+                <role>PMC</role>
+            </roles>
+            <timezone>Europe/Bratislava</timezone>
+        </developer>
+    </developers>
+
+    <dependencies>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.12</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <source>1.5</source>
+                    <target>1.5</target>
+                </configuration>
+            </plugin>
+        </plugins>
+        <pluginManagement>
+            <plugins>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-surefire-plugin</artifactId>
+                    <version>${surefire.version}</version>
+                    <configuration>
+                        <forkMode>once</forkMode>
+                        <forkCount>1</forkCount>
+                        <skipAfterFailureCount>2</skipAfterFailureCount>
+                        <rerunFailingTestsCount>3</rerunFailingTestsCount>
+                    </configuration>
+                </plugin>
+            </plugins>
+        </pluginManagement>
+    </build>
+
+    <profiles>
+        <profile>
+            <id>junit47</id>
+            <activation>
+                <activeByDefault>true</activeByDefault>
+            </activation>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-surefire-plugin</artifactId>
+                        <dependencies>
+                            <dependency>
+                                <groupId>org.apache.maven.surefire</groupId>
+                                <artifactId>surefire-junit47</artifactId>
+                                <version>${surefire.version}</version>
+                            </dependency>
+                        </dependencies>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+        <profile>
+            <id>junit4</id>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-surefire-plugin</artifactId>
+                        <dependencies>
+                            <dependency>
+                                <groupId>org.apache.maven.surefire</groupId>
+                                <artifactId>surefire-junit4</artifactId>
+                                <version>${surefire.version}</version>
+                            </dependency>
+                        </dependencies>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
+
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7f64ddbf/surefire-integration-tests/src/test/resources/surefire-1202-rerun-and-failfast/src/test/java/pkg/ATest.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/surefire-1202-rerun-and-failfast/src/test/java/pkg/ATest.java b/surefire-integration-tests/src/test/resources/surefire-1202-rerun-and-failfast/src/test/java/pkg/ATest.java
new file mode 100644
index 0000000..cbe3f6f
--- /dev/null
+++ b/surefire-integration-tests/src/test/resources/surefire-1202-rerun-and-failfast/src/test/java/pkg/ATest.java
@@ -0,0 +1,45 @@
+package pkg;
+
+/*
+ * 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.
+ */
+
+import org.junit.Test;
+
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static java.util.concurrent.TimeUnit.SECONDS;
+
+public class ATest
+{
+    private static int count;
+
+    @Test
+    public void testA()
+            throws Exception
+    {
+        MILLISECONDS.sleep( 500 );
+        if ( count++ != 2 )
+        {
+            throw new RuntimeException( "assert \"foo\" == \"bar\"\n"
+                                                + "             |\n"
+                                                + "             false"
+            );
+        }
+        SECONDS.sleep( 5 );
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7f64ddbf/surefire-integration-tests/src/test/resources/surefire-1202-rerun-and-failfast/src/test/java/pkg/BTest.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/surefire-1202-rerun-and-failfast/src/test/java/pkg/BTest.java b/surefire-integration-tests/src/test/resources/surefire-1202-rerun-and-failfast/src/test/java/pkg/BTest.java
new file mode 100644
index 0000000..f44d396
--- /dev/null
+++ b/surefire-integration-tests/src/test/resources/surefire-1202-rerun-and-failfast/src/test/java/pkg/BTest.java
@@ -0,0 +1,42 @@
+package pkg;
+
+/*
+ * 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.
+ */
+
+import org.junit.Test;
+
+import static java.util.concurrent.TimeUnit.SECONDS;
+
+public class BTest
+{
+
+    private static int count;
+
+    @Test
+    public void testB()
+            throws InterruptedException
+    {
+        SECONDS.sleep( 2 );
+        if ( count++ != 2 )
+        {
+            throw new RuntimeException();
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7f64ddbf/surefire-integration-tests/src/test/resources/surefire-1202-rerun-and-failfast/src/test/java/pkg/CTest.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/surefire-1202-rerun-and-failfast/src/test/java/pkg/CTest.java b/surefire-integration-tests/src/test/resources/surefire-1202-rerun-and-failfast/src/test/java/pkg/CTest.java
new file mode 100644
index 0000000..e51a29d
--- /dev/null
+++ b/surefire-integration-tests/src/test/resources/surefire-1202-rerun-and-failfast/src/test/java/pkg/CTest.java
@@ -0,0 +1,35 @@
+package pkg;
+
+/*
+ * 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.
+ */
+
+import org.junit.Test;
+
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+
+public class CTest
+{
+    @Test
+    public void testC()
+            throws InterruptedException
+    {
+        MILLISECONDS.sleep( 500 );
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7f64ddbf/surefire-integration-tests/src/test/resources/surefire-1202-rerun-and-failfast/src/test/java/pkg/DTest.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/surefire-1202-rerun-and-failfast/src/test/java/pkg/DTest.java b/surefire-integration-tests/src/test/resources/surefire-1202-rerun-and-failfast/src/test/java/pkg/DTest.java
new file mode 100644
index 0000000..85bc666
--- /dev/null
+++ b/surefire-integration-tests/src/test/resources/surefire-1202-rerun-and-failfast/src/test/java/pkg/DTest.java
@@ -0,0 +1,35 @@
+package pkg;
+
+/*
+ * 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.
+ */
+
+import org.junit.Test;
+
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+
+public class DTest
+{
+    @Test
+    public void testD()
+            throws InterruptedException
+    {
+        MILLISECONDS.sleep( 500 );
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7f64ddbf/surefire-integration-tests/src/test/resources/surefire-1202-rerun-and-failfast/src/test/java/pkg/ETest.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/surefire-1202-rerun-and-failfast/src/test/java/pkg/ETest.java b/surefire-integration-tests/src/test/resources/surefire-1202-rerun-and-failfast/src/test/java/pkg/ETest.java
new file mode 100644
index 0000000..a74e734
--- /dev/null
+++ b/surefire-integration-tests/src/test/resources/surefire-1202-rerun-and-failfast/src/test/java/pkg/ETest.java
@@ -0,0 +1,31 @@
+package pkg;
+
+/*
+ * 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.
+ */
+
+import org.junit.Test;
+
+public class ETest
+{
+    @Test
+    public void test()
+            throws InterruptedException
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7f64ddbf/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/Notifier.java
----------------------------------------------------------------------
diff --git a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/Notifier.java b/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/Notifier.java
index 0cd8d98..20b711e 100644
--- a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/Notifier.java
+++ b/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/Notifier.java
@@ -43,7 +43,7 @@ import static org.apache.maven.surefire.util.internal.ConcurrencyUtils.countDown
  * @author <a href="mailto:tibordigana@apache.org">Tibor Digana (tibor17)</a>
  * @since 2.19
  */
-public final class Notifier
+public class Notifier
     extends RunNotifier
 {
     private final Collection<RunListener> listeners = new ArrayList<RunListener>();
@@ -63,23 +63,49 @@ public final class Notifier
         this.skipAfterFailureCount = new AtomicInteger( skipAfterFailureCount );
     }
 
+    private Notifier()
+    {
+        reporter = null;
+        skipAfterFailureCount = null;
+    }
+
+    public static Notifier pureNotifier()
+    {
+        return new Notifier()
+        {
+            @Override
+            public Notifier asFailFast( boolean failFast )
+            {
+                throw new UnsupportedOperationException( "pure notifier" );
+            }
+        };
+    }
+
     public Notifier asFailFast( boolean failFast )
     {
         this.failFast = failFast;
         return this;
     }
 
+    public final boolean isFailFast()
+    {
+        return failFast;
+    }
+
     @Override
-    public void fireTestStarted( Description description ) throws StoppedByUserException
+    public final void fireTestStarted( Description description ) throws StoppedByUserException
     {
         // If fireTestStarted() throws exception (== skipped test), the class must not be removed from testClassNames.
         // Therefore this class will be removed only if test class started with some test method.
         super.fireTestStarted( description );
-        testClassNames.remove( cutTestClassAndMethod( description ).getClazz() );
+        if ( !testClassNames.isEmpty() )
+        {
+            testClassNames.remove( cutTestClassAndMethod( description ).getClazz() );
+        }
     }
 
     @Override
-    public void fireTestFailure( Failure failure )
+    public final void fireTestFailure( Failure failure )
     {
         if ( failFast )
         {
@@ -88,27 +114,14 @@ public final class Notifier
         super.fireTestFailure( failure );
     }
 
-    /**
-     * Fire stop even to plugin process and/or call {@link org.junit.runner.notification.RunNotifier#pleaseStop()}.
-     */
-    private void fireStopEvent()
-    {
-        if ( countDownToZero( skipAfterFailureCount ) )
-        {
-            pleaseStop();
-        }
-
-        reporter.testExecutionSkippedByUser();
-    }
-
     @Override
-    public void addListener( RunListener listener )
+    public final void addListener( RunListener listener )
     {
         listeners.add( listener );
         super.addListener( listener );
     }
 
-    public Notifier addListeners( Collection<RunListener> given )
+    public final Notifier addListeners( Collection<RunListener> given )
     {
         for ( RunListener listener : given )
         {
@@ -117,7 +130,7 @@ public final class Notifier
         return this;
     }
 
-    public Notifier addListeners( RunListener... given )
+    public final Notifier addListeners( RunListener... given )
     {
         for ( RunListener listener : given )
         {
@@ -127,13 +140,13 @@ public final class Notifier
     }
 
     @Override
-    public void removeListener( RunListener listener )
+    public final void removeListener( RunListener listener )
     {
         listeners.remove( listener );
         super.removeListener( listener );
     }
 
-    public void removeListeners()
+    public final void removeListeners()
     {
         for ( Iterator<RunListener> it = listeners.iterator(); it.hasNext(); )
         {
@@ -143,8 +156,26 @@ public final class Notifier
         }
     }
 
-    public Queue<String> getRemainingTestClasses()
+    public final Queue<String> getRemainingTestClasses()
+    {
+        return failFast ? testClassNames : null;
+    }
+
+    public final void copyListenersTo( Notifier copyTo )
+    {
+        copyTo.addListeners( listeners );
+    }
+
+    /**
+     * Fire stop even to plugin process and/or call {@link org.junit.runner.notification.RunNotifier#pleaseStop()}.
+     */
+    private void fireStopEvent()
     {
-        return testClassNames;
+        if ( countDownToZero( skipAfterFailureCount ) )
+        {
+            pleaseStop();
+        }
+
+        reporter.testExecutionSkippedByUser();
     }
 }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7f64ddbf/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java b/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java
index fa767eb..b286bbf 100644
--- a/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java
+++ b/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java
@@ -46,6 +46,7 @@ import org.junit.runner.Description;
 import org.junit.runner.Result;
 import org.junit.runner.Runner;
 import org.junit.runner.manipulation.Filter;
+import org.junit.runner.notification.RunNotifier;
 import org.junit.runner.notification.StoppedByUserException;
 
 import java.util.Collection;
@@ -61,6 +62,7 @@ import static org.apache.maven.surefire.common.junit4.JUnit4Reflector.createDesc
 import static org.apache.maven.surefire.common.junit4.JUnit4Reflector.createIgnored;
 import static org.apache.maven.surefire.common.junit4.JUnit4RunListener.rethrowAnyTestMechanismFailures;
 import static org.apache.maven.surefire.common.junit4.JUnit4RunListenerFactory.createCustomListeners;
+import static org.apache.maven.surefire.common.junit4.Notifier.pureNotifier;
 import static org.apache.maven.surefire.report.ConsoleOutputCapture.startCapture;
 import static org.apache.maven.surefire.report.SimpleReportEntry.withException;
 import static org.apache.maven.surefire.testset.TestListResolver.optionallyWildcardFilter;
@@ -116,11 +118,6 @@ public class JUnit4Provider
     public RunResult invoke( Object forkTestSet )
         throws TestSetFailedException
     {
-        if ( isRerunFailingTests() && isFailFast() )
-        {
-            throw new TestSetFailedException( "don't enable parameters rerunFailingTestsCount, skipAfterFailureCount" );
-        }
-
         upgradeCheck();
 
         ReporterFactory reporterFactory = providerParameters.getReporterFactory();
@@ -208,7 +205,7 @@ public class JUnit4Provider
 
     private int getSkipAfterFailureCount()
     {
-        return isFailFast() && !isRerunFailingTests() ? providerParameters.getSkipAfterFailureCount() : 0;
+        return isFailFast() ? providerParameters.getSkipAfterFailureCount() : 0;
     }
 
     private void registerShutdownListener( final TestsToRun testsToRun )
@@ -285,13 +282,15 @@ public class JUnit4Provider
             // Rerun failing tests if rerunFailingTestsCount is larger than 0
             if ( isRerunFailingTests() )
             {
+                Notifier rerunNotifier = pureNotifier();
+                notifier.copyListenersTo( rerunNotifier );
                 for ( int i = 0; i < rerunFailingTestsCount && !failureListener.getAllFailures().isEmpty(); i++ )
                 {
                     Set<ClassMethod> failedTests = generateFailingTests( failureListener.getAllFailures() );
                     failureListener.reset();
                     if ( !failedTests.isEmpty() )
                     {
-                        executeFailedMethod( notifier, failedTests );
+                        executeFailedMethod( rerunNotifier, failedTests );
                     }
                 }
             }
@@ -366,7 +365,7 @@ public class JUnit4Provider
         }
     }
 
-    private void executeFailedMethod( Notifier notifier, Set<ClassMethod> failedMethods )
+    private void executeFailedMethod( RunNotifier notifier, Set<ClassMethod> failedMethods )
         throws TestSetFailedException
     {
         for ( ClassMethod failedMethod : failedMethods )

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7f64ddbf/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java
index 1b45a26..606911c 100644
--- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java
+++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java
@@ -53,6 +53,7 @@ import static java.util.Collections.unmodifiableCollection;
 import static org.apache.maven.surefire.booter.CommandReader.getReader;
 import static org.apache.maven.surefire.common.junit4.JUnit4ProviderUtil.generateFailingTests;
 import static org.apache.maven.surefire.common.junit4.JUnit4RunListenerFactory.createCustomListeners;
+import static org.apache.maven.surefire.common.junit4.Notifier.pureNotifier;
 import static org.apache.maven.surefire.junitcore.ConcurrentRunListener.createInstance;
 import static org.apache.maven.surefire.report.ConsoleOutputCapture.startCapture;
 import static org.apache.maven.surefire.testset.TestListResolver.optionallyWildcardFilter;
@@ -120,11 +121,6 @@ public class JUnitCoreProvider
     public RunResult invoke( Object forkTestSet )
         throws TestSetFailedException
     {
-        if ( isRerunFailingTests() && isFailFast() )
-        {
-            throw new TestSetFailedException( "don't enable parameters rerunFailingTestsCount, skipAfterFailureCount" );
-        }
-
         final ReporterFactory reporterFactory = providerParameters.getReporterFactory();
 
         final RunResult runResult;
@@ -153,7 +149,7 @@ public class JUnitCoreProvider
 
         try
         {
-            JUnitCoreWrapper core = new JUnitCoreWrapper( notifier, jUnitCoreParameters, consoleLogger, isFailFast() );
+            JUnitCoreWrapper core = new JUnitCoreWrapper( notifier, jUnitCoreParameters, consoleLogger );
 
             if ( commandsReader != null )
             {
@@ -161,11 +157,16 @@ public class JUnitCoreProvider
                 commandsReader.awaitStarted();
             }
 
+            notifier.asFailFast( isFailFast() );
             core.execute( testsToRun, customRunListeners, filter );
+            notifier.asFailFast( false );
 
             // Rerun failing tests if rerunFailingTestsCount is larger than 0
             if ( isRerunFailingTests() )
             {
+                Notifier rerunNotifier = pureNotifier();
+                notifier.copyListenersTo( rerunNotifier );
+                JUnitCoreWrapper rerunCore = new JUnitCoreWrapper( rerunNotifier, jUnitCoreParameters, consoleLogger );
                 for ( int i = 0; i < rerunFailingTestsCount && !testFailureListener.getAllFailures().isEmpty(); i++ )
                 {
                     List<Failure> failures = testFailureListener.getAllFailures();
@@ -173,7 +174,7 @@ public class JUnitCoreProvider
                     testFailureListener.reset();
                     FilterFactory filterFactory = new FilterFactory( testClassLoader );
                     Filter failingMethodsFilter = filterFactory.createFailingMethodFilter( failingTests );
-                    core.execute( testsToRun, failingMethodsFilter );
+                    rerunCore.execute( testsToRun, failingMethodsFilter );
                 }
             }
         }
@@ -215,7 +216,7 @@ public class JUnitCoreProvider
 
     private int getSkipAfterFailureCount()
     {
-        return isFailFast() && !isRerunFailingTests() ? providerParameters.getSkipAfterFailureCount() : 0;
+        return isFailFast() ? providerParameters.getSkipAfterFailureCount() : 0;
     }
 
     private void registerShutdownListener( final TestsToRun testsToRun )

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7f64ddbf/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreWrapper.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreWrapper.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreWrapper.java
index 7ae3e75..21858fe 100644
--- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreWrapper.java
+++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreWrapper.java
@@ -55,15 +55,12 @@ final class JUnitCoreWrapper
     private final Notifier notifier;
     private final JUnitCoreParameters jUnitCoreParameters;
     private final ConsoleLogger logger;
-    private final boolean failFast;
 
-    JUnitCoreWrapper( Notifier notifier, JUnitCoreParameters jUnitCoreParameters, ConsoleLogger logger,
-                      boolean failFast )
+    JUnitCoreWrapper( Notifier notifier, JUnitCoreParameters jUnitCoreParameters, ConsoleLogger logger )
     {
         this.notifier = notifier;
         this.jUnitCoreParameters = jUnitCoreParameters;
         this.logger = logger;
-        this.failFast = failFast;
     }
 
     void execute( TestsToRun testsToRun, Filter filter )
@@ -162,12 +159,12 @@ final class JUnitCoreWrapper
     {
         JUnitCore()
         {
-            super( JUnitCoreWrapper.this.notifier.asFailFast( JUnitCoreWrapper.this.failFast ) );
+            super( JUnitCoreWrapper.this.notifier );
         }
 
         JUnitCore withReportedTests( Class<?>... tests )
         {
-            Queue<String> stoppedTests = getRemainingTestClasses();
+            Queue<String> stoppedTests = JUnitCoreWrapper.this.notifier.getRemainingTestClasses();
             if ( stoppedTests != null )
             {
                 for ( Class<?> test : tests )
@@ -183,9 +180,9 @@ final class JUnitCoreWrapper
         protected void afterException( Throwable e )
             throws TestSetFailedException
         {
-            if ( JUnitCoreWrapper.this.failFast && e instanceof StoppedByUserException )
+            if ( JUnitCoreWrapper.this.notifier.isFailFast() && e instanceof StoppedByUserException )
             {
-                Queue<String> stoppedTests = getRemainingTestClasses();
+                Queue<String> stoppedTests = JUnitCoreWrapper.this.notifier.getRemainingTestClasses();
                 if ( stoppedTests != null )
                 {
                     String reason = e.getClass().getName();
@@ -206,16 +203,11 @@ final class JUnitCoreWrapper
         @Override
         protected void afterFinished()
         {
-            Queue<String> stoppedTests = getRemainingTestClasses();
+            Queue<String> stoppedTests = JUnitCoreWrapper.this.notifier.getRemainingTestClasses();
             if ( stoppedTests != null )
             {
                 stoppedTests.clear();
             }
         }
-
-        private Queue<String> getRemainingTestClasses()
-        {
-            return JUnitCoreWrapper.this.failFast ? JUnitCoreWrapper.this.notifier.getRemainingTestClasses() : null;
-        }
     }
 }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/7f64ddbf/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/Surefire746Test.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/Surefire746Test.java b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/Surefire746Test.java
index 46213df..635279d 100644
--- a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/Surefire746Test.java
+++ b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/Surefire746Test.java
@@ -115,7 +115,7 @@ public class Surefire746Test
             // and rethrows a failure which happened in listener
             exception.expect( TestSetFailedException.class );
             JUnit4RunListener dummy = new JUnit4RunListener( new MockReporter() );
-            new JUnitCoreWrapper( new Notifier( dummy, 0 ), jUnitCoreParameters, new Logger(), false )
+            new JUnitCoreWrapper( new Notifier( dummy, 0 ), jUnitCoreParameters, new Logger() )
                 .execute( testsToRun, customRunListeners, null );
         }
         finally