maven-surefire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krosenv...@apache.org
Subject svn commit: r1058166 - in /maven/surefire/trunk: surefire-api/src/main/java/org/apache/maven/surefire/report/ surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ surefire-providers/common-junit4/src/main/java/org/apache/maven/surefi...
Date Wed, 12 Jan 2011 15:04:22 GMT
Author: krosenvold
Date: Wed Jan 12 15:04:21 2011
New Revision: 1058166

URL: http://svn.apache.org/viewvc?rev=1058166&view=rev
Log:
[SUREFIRE-542] JUnit 4.4 tests skipped for a failed assumption are not reported as Skipped

Modified:
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterManager.java
    maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire613TestCountInParallelIT.java
    maven/surefire/trunk/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListener.java
    maven/surefire/trunk/surefire-providers/common-junit4/src/test/java/org/apache/maven/surefire/common/junit4/JUnit4RunListenerTest.java
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConcurrentReporterManager.java
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestMethod.java
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnitCoreRunListenerTest.java

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterManager.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterManager.java?rev=1058166&r1=1058165&r2=1058166&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterManager.java
(original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterManager.java
Wed Jan 12 15:04:21 2011
@@ -175,13 +175,14 @@ public class ReporterManager
         multicastingReporter.testSkipped( report );
     }
 
-    public void reset()
+    public void testAssumptionFailure( ReportEntry report )
     {
-        multicastingReporter.reset();
+        testSkipped( report );
     }
 
-    public void testAssumptionFailure( ReportEntry report )
+    public void reset()
     {
-        // Ignore for now.
+        multicastingReporter.reset();
     }
+
 }

Modified: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire613TestCountInParallelIT.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire613TestCountInParallelIT.java?rev=1058166&r1=1058165&r2=1058166&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire613TestCountInParallelIT.java
(original)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire613TestCountInParallelIT.java
Wed Jan 12 15:04:21 2011
@@ -45,6 +45,6 @@ public class Surefire613TestCountInParal
         verifyTextInLog( "testWithException1 to stdout" );
         verifyTextInLog( "testWithException1 to stderr" );
 
-        assertTestSuiteResults( 15, 8, 4, 2 );
+        assertTestSuiteResults( 30, 8, 4, 17 );
     }
-}
\ No newline at end of file
+}

Modified: maven/surefire/trunk/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListener.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListener.java?rev=1058166&r1=1058165&r2=1058166&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListener.java
(original)
+++ maven/surefire/trunk/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListener.java
Wed Jan 12 15:04:21 2011
@@ -22,14 +22,13 @@ package org.apache.maven.surefire.common
 import org.apache.maven.surefire.report.ReportEntry;
 import org.apache.maven.surefire.report.Reporter;
 import org.apache.maven.surefire.report.SimpleReportEntry;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
 import org.junit.runner.Description;
 import org.junit.runner.notification.Failure;
 import org.junit.runner.notification.RunListener;
 
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
 public class JUnit4RunListener
     extends RunListener
 {
@@ -102,10 +101,16 @@ public class JUnit4RunListener
         {
             this.reporter.testError( report );
         }
+        failureFlag = true;
+    }
 
+    public void testAssumptionFailure( Failure failure )
+    {
+        this.reporter.testAssumptionFailure( createReportEntry( failure.getDescription()
) );
         failureFlag = true;
     }
 
+
     /**
      * Called after a specific test has finished.
      *
@@ -126,11 +131,6 @@ public class JUnit4RunListener
     }
 
 
-    public void testAssumptionFailure( Failure failure )
-    {
-        this.reporter.testAssumptionFailure( createReportEntry( failure.getDescription()
) );
-    }
-
     protected String extractClassName( Description description )
     {
         String displayName = description.getDisplayName();

Modified: maven/surefire/trunk/surefire-providers/common-junit4/src/test/java/org/apache/maven/surefire/common/junit4/JUnit4RunListenerTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/common-junit4/src/test/java/org/apache/maven/surefire/common/junit4/JUnit4RunListenerTest.java?rev=1058166&r1=1058165&r2=1058166&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/common-junit4/src/test/java/org/apache/maven/surefire/common/junit4/JUnit4RunListenerTest.java
(original)
+++ maven/surefire/trunk/surefire-providers/common-junit4/src/test/java/org/apache/maven/surefire/common/junit4/JUnit4RunListenerTest.java
Wed Jan 12 15:04:21 2011
@@ -63,4 +63,5 @@ public class JUnit4RunListenerTest
 
         }
     }
+
 }

Modified: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConcurrentReporterManager.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConcurrentReporterManager.java?rev=1058166&r1=1058165&r2=1058166&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConcurrentReporterManager.java
(original)
+++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConcurrentReporterManager.java
Wed Jan 12 15:04:21 2011
@@ -91,11 +91,6 @@ public abstract class ConcurrentReporter
         }
     }
 
-    public void testAssumptionFailure( ReportEntry failure )
-    {
-        getOrCreateTestMethod( failure ).testAssumptionFailure( failure );
-    }
-
     public void testFailed( ReportEntry failure )
     {
         getOrCreateTestMethod( failure ).testFailure( failure );
@@ -106,7 +101,6 @@ public abstract class ConcurrentReporter
         getOrCreateTestMethod( failure ).testError( failure );
     }
 
-
     public void testSkipped( ReportEntry description )
     {
         TestSet testSet = getTestSet( description );
@@ -115,6 +109,11 @@ public abstract class ConcurrentReporter
         testSet.incrementFinishedTests( getReporterManager(), reportImmediately );
     }
 
+    public void testAssumptionFailure( ReportEntry failure )
+    {
+        getOrCreateTestMethod( failure ).testIgnored( failure );
+    }
+
     public void testStarting( ReportEntry description )
     {
         TestSet testSet = getTestSet( description );

Modified: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestMethod.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestMethod.java?rev=1058166&r1=1058165&r2=1058166&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestMethod.java
(original)
+++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestMethod.java
Wed Jan 12 15:04:21 2011
@@ -40,8 +40,6 @@ class TestMethod
 
     private volatile ReportEntry testError;
 
-    private volatile ReportEntry testAssumptionFailure;
-
     private volatile ReportEntry ignored;
 
     private static final InheritableThreadLocal<TestMethod> TEST_METHOD = new InheritableThreadLocal<TestMethod>();
@@ -70,12 +68,6 @@ class TestMethod
         this.testFailure = failure;
     }
 
-    public void testAssumptionFailure( ReportEntry testAssumptionFailure )
-    {
-        this.testAssumptionFailure = testAssumptionFailure;
-        setEndTime();
-    }
-
     public void testError( ReportEntry failure )
     {
         this.testError = failure;
@@ -117,10 +109,6 @@ class TestMethod
         {
             reporter.testError( testError, getStdout(), getStdErr() );
         }
-        else if ( testAssumptionFailure != null )
-        {
-            // Does nothing...
-        }
         else
         {
             reporter.testSucceeded( createReportEntry() );

Modified: maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnitCoreRunListenerTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnitCoreRunListenerTest.java?rev=1058166&r1=1058165&r2=1058166&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnitCoreRunListenerTest.java
(original)
+++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnitCoreRunListenerTest.java
Wed Jan 12 15:04:21 2011
@@ -1,16 +1,16 @@
 package org.apache.maven.surefire.junitcore;
 
 import org.apache.maven.surefire.report.MulticastingReporter;
-
-import java.util.Collections;
-import java.util.HashMap;
-
+import org.junit.Assume;
 import org.junit.Test;
 import org.junit.runner.Computer;
 import org.junit.runner.JUnitCore;
 import org.junit.runner.Result;
 import org.junit.runner.notification.RunListener;
 
+import java.util.Collections;
+import java.util.HashMap;
+
 import static junit.framework.Assert.assertEquals;
 
 /**
@@ -30,6 +30,18 @@ public class JUnitCoreRunListenerTest
         core.removeListener(  jUnit4TestSetReporter );
         assertEquals(2, result.getRunCount());
     }
+    @Test
+    public void failedAssumption()
+        throws Exception
+    {
+        RunListener jUnit4TestSetReporter = new JUnitCoreRunListener( new MulticastingReporter(
Collections.emptyList() ),
+                                                                      new HashMap<String,
TestSet>(  ) );
+        JUnitCore core = new JUnitCore();
+        core.addListener(  jUnit4TestSetReporter );
+        Result result = core.run( new Computer(), TestWithAssumptionFailure.class);
+        core.removeListener(  jUnit4TestSetReporter );
+        assertEquals(1, result.getRunCount());
+    }
 
 
     public static class STest1
@@ -46,4 +58,15 @@ public class JUnitCoreRunListenerTest
 
         }
     }
+
+    public static class TestWithAssumptionFailure
+    {
+        @Test
+        public void testSomething2()
+        {
+            Assume.assumeTrue(false);
+
+        }
+    }
+
 }



Mime
View raw message