Repository: maven-surefire
Updated Branches:
  refs/heads/master 100f69602 -> 67c06d587


[SUREFIRE-1409] Parallel runner should not drop away runners that have zero 
children.


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

Branch: refs/heads/master
Commit: 67c06d5876dcabc037de9b5f4cc226beeedcb379
Parents: 100f696
Author: Fedor Bobin <[email protected]>
Authored: Tue Jul 12 15:10:37 2016 +0300
Committer: Tibor17 <[email protected]>
Committed: Fri Sep 8 22:03:50 2017 +0200

----------------------------------------------------------------------
 .../junitcore/pc/ParallelComputerBuilder.java   |  5 +-
 .../pc/ParallelComputerBuilderTest.java         | 68 ++++++++++++++++++++
 2 files changed, 69 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/67c06d58/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilder.java
----------------------------------------------------------------------
diff --git 
a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilder.java
 
b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilder.java
old mode 100644
new mode 100755
index 92ee18c..fd0cab3
--- 
a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilder.java
+++ 
b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilder.java
@@ -429,10 +429,7 @@ public final class ParallelComputerBuilder
                 {
                     int children = countChildren( runner );
                     childrenCounter += children;
-                    if ( children != 0 )
-                    {
-                        runs.add( runner );
-                    }
+                    runs.add( runner );
                 }
             }
             return runs.isEmpty() ? new WrappedRunners() : new WrappedRunners( 
createSuite( runs ), childrenCounter );

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/67c06d58/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilderTest.java
----------------------------------------------------------------------
diff --git 
a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilderTest.java
 
b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilderTest.java
old mode 100644
new mode 100755
index bef7baf..212e157
--- 
a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilderTest.java
+++ 
b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/pc/ParallelComputerBuilderTest.java
@@ -33,7 +33,10 @@ import org.junit.runner.Description;
 import org.junit.runner.JUnitCore;
 import org.junit.runner.Result;
 import org.junit.runner.RunWith;
+import org.junit.runner.notification.RunNotifier;
+import org.junit.runners.ParentRunner;
 import org.junit.runners.Suite;
+import org.junit.runners.model.InitializationError;
 
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -42,6 +45,7 @@ import java.util.Collections;
 import java.util.Comparator;
 import java.util.Date;
 import java.util.Iterator;
+import java.util.List;
 import java.util.concurrent.ConcurrentLinkedQueue;
 import java.util.concurrent.TimeUnit;
 
@@ -105,6 +109,15 @@ public class ParallelComputerBuilderTest
     }
 
     @Test
+    public void testsWithoutChildrenShouldAlsoBeRun()
+    {
+        ParallelComputerBuilder parallelComputerBuilder = new 
ParallelComputerBuilder( logger );
+        ParallelComputerBuilder.PC computer = ( ParallelComputerBuilder.PC ) 
parallelComputerBuilder.buildComputer();
+        Result result = new JUnitCore().run( computer, 
TestWithoutPrecalculatedChildren.class );
+        assertThat( result.getRunCount(), is( 1 ) );
+    }
+
+    @Test
     public void parallelMethodsReuseOneOrTwoThreads()
     {
         ParallelComputerBuilder parallelComputerBuilder = new 
ParallelComputerBuilder( logger );
@@ -689,6 +702,61 @@ public class ParallelComputerBuilderTest
     {
     }
 
+    public static class Test2
+    {
+        @Test
+        public void test()
+        {
+
+        }
+    }
+
+    @RunWith( ReportOneTestAtRuntimeRunner.class )
+    public static class TestWithoutPrecalculatedChildren {}
+
+    public static class ReportOneTestAtRuntimeRunner
+            extends ParentRunner
+    {
+        private final Class testClass;
+        private final Description suiteDescription;
+        private Description myTestMethodDescr;
+
+        public ReportOneTestAtRuntimeRunner( Class testClass ) throws 
InitializationError
+        {
+            super( Object.class );
+            this.testClass = testClass;
+            suiteDescription = Description.createSuiteDescription( testClass );
+            myTestMethodDescr = Description.createTestDescription( testClass, 
"my_test" );
+//            suiteDescription.addChild(myTestMethodDescr); // let it be not 
known at start time
+        }
+
+        protected List getChildren()
+        {
+            throw new UnsupportedOperationException( "workflow from 
ParentRunner not supported" );
+        }
+
+        protected Description describeChild( Object child )
+        {
+            throw new UnsupportedOperationException( "workflow from 
ParentRunner not supported" );
+        }
+
+        protected void runChild( Object child, RunNotifier notifier )
+        {
+            throw new UnsupportedOperationException( "workflow from 
ParentRunner not supported" );
+        }
+
+        public Description getDescription()
+        {
+            return suiteDescription;
+        }
+
+        public void run( RunNotifier notifier )
+        {
+            notifier.fireTestStarted( myTestMethodDescr );
+            notifier.fireTestFinished( Description.createTestDescription( 
testClass, "my_test" ) );
+        }
+    }
+
     @NotThreadSafe
     public static class NotThreadSafeTest1
     {

Reply via email to