Repository: maven-surefire
Updated Branches:
  refs/heads/master c2a7d4b7f -> d9b577cdc


[SUREFIRE-1311] JUnit47 provider should not internally parse JUnit Description


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

Branch: refs/heads/master
Commit: d9b577cdc991d09116282d89ca69b5d2768acb0e
Parents: c2a7d4b
Author: Tibor17 <tibo...@lycos.com>
Authored: Fri Dec 2 04:36:13 2016 +0100
Committer: Tibor17 <tibo...@lycos.com>
Committed: Fri Dec 2 04:36:13 2016 +0100

----------------------------------------------------------------------
 .../common/junit4/JUnit4RunListener.java        | 18 +++++++++++---
 .../common/junit4/JUnit4StackTraceWriter.java   | 14 ++++++-----
 surefire-providers/common-junit48/pom.xml       |  6 +++++
 .../common/junit48/JUnit46StackTraceWriter.java |  9 ++++---
 .../junitcore/JUnitCoreRunListener.java         | 18 +++++++++++---
 .../junitcore/NonConcurrentRunListener.java     | 26 ++++++++++++++------
 6 files changed, 68 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/d9b577cd/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListener.java
----------------------------------------------------------------------
diff --git 
a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListener.java
 
b/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListener.java
index 85e2acd..dd004fa 100644
--- 
a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListener.java
+++ 
b/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListener.java
@@ -120,7 +120,7 @@ public class JUnit4RunListener
         failureFlag.set( true );
     }
 
-    @SuppressWarnings( { "UnusedDeclaration" } )
+    @SuppressWarnings( "UnusedDeclaration" )
     public void testAssumptionFailure( Failure failure )
     {
         Description desc = failure.getDescription();
@@ -152,16 +152,16 @@ public class JUnit4RunListener
         reporter.testExecutionSkippedByUser();
     }
 
-    private static String getClassName( Description description )
+    private String getClassName( Description description )
     {
-        String name = extractClassName( description );
+        String name = extractDescriptionClassName( description );
         if ( name == null || isInsaneJunitNullString( name ) )
         {
             // This can happen upon early failures (class instantiation error 
etc)
             Description subDescription = description.getChildren().get( 0 );
             if ( subDescription != null )
             {
-                name = extractClassName( subDescription );
+                name = extractDescriptionClassName( subDescription );
             }
             if ( name == null )
             {
@@ -181,6 +181,16 @@ public class JUnit4RunListener
         return new SimpleReportEntry( getClassName( description ), 
description.getDisplayName() );
     }
 
+    protected String extractDescriptionClassName( Description description )
+    {
+        return extractClassName( description );
+    }
+
+    protected String extractDescriptionMethodName( Description description )
+    {
+        return extractMethodName( description );
+    }
+
     public static String extractClassName( Description description )
     {
         String displayName = description.getDisplayName();

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/d9b577cd/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4StackTraceWriter.java
----------------------------------------------------------------------
diff --git 
a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4StackTraceWriter.java
 
b/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4StackTraceWriter.java
index 8292d4b..a4690ca 100644
--- 
a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4StackTraceWriter.java
+++ 
b/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4StackTraceWriter.java
@@ -22,9 +22,12 @@ package org.apache.maven.surefire.common.junit4;
 import org.apache.maven.surefire.report.SafeThrowable;
 import org.apache.maven.surefire.report.SmartStackTraceParser;
 import org.apache.maven.surefire.report.StackTraceWriter;
-
 import org.junit.runner.notification.Failure;
 
+import static 
org.apache.maven.surefire.common.junit4.JUnit4RunListener.extractClassName;
+import static 
org.apache.maven.surefire.common.junit4.JUnit4RunListener.extractMethodName;
+import static 
org.apache.maven.surefire.report.SmartStackTraceParser.stackTraceWithFocusOnClassAsString;
+
 /**
  * Writes out a specific {@link org.junit.runner.notification.Failure} for
  * surefire as a stacktrace.
@@ -74,15 +77,14 @@ public class JUnit4StackTraceWriter
         return "";
     }
 
-
     protected String getTestClassName()
     {
-        return JUnit4RunListener.extractClassName( 
junitFailure.getDescription() );
+        return extractClassName( junitFailure.getDescription() );
     }
 
     protected String getTestMethodName()
     {
-        return JUnit4RunListener.extractMethodName( 
junitFailure.getDescription() );
+        return extractMethodName( junitFailure.getDescription() );
     }
 
     @SuppressWarnings( "ThrowableResultOfMethodCallIgnored" )
@@ -105,11 +107,11 @@ public class JUnit4StackTraceWriter
         try
         {
             Throwable e = junitFailure.getException();
-            return SmartStackTraceParser.stackTraceWithFocusOnClassAsString( 
e, testClass );
+            return stackTraceWithFocusOnClassAsString( e, testClass );
         }
         catch ( Throwable t )
         {
-            return SmartStackTraceParser.stackTraceWithFocusOnClassAsString( 
t, testClass );
+            return stackTraceWithFocusOnClassAsString( t, testClass );
         }
     }
 

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/d9b577cd/surefire-providers/common-junit48/pom.xml
----------------------------------------------------------------------
diff --git a/surefire-providers/common-junit48/pom.xml 
b/surefire-providers/common-junit48/pom.xml
index 5cd10fa..e6e6976 100644
--- a/surefire-providers/common-junit48/pom.xml
+++ b/surefire-providers/common-junit48/pom.xml
@@ -42,6 +42,12 @@
       <groupId>org.apache.maven.surefire</groupId>
       <artifactId>common-junit4</artifactId>
       <version>${project.version}</version>
+      <exclusions>
+        <exclusion>
+          <groupId>junit</groupId>
+          <artifactId>junit</artifactId>
+        </exclusion>
+      </exclusions>
     </dependency>
     <dependency>
       <groupId>org.apache.maven.surefire</groupId>

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/d9b577cd/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/JUnit46StackTraceWriter.java
----------------------------------------------------------------------
diff --git 
a/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/JUnit46StackTraceWriter.java
 
b/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/JUnit46StackTraceWriter.java
index 72f0b00..c7f2bd7 100644
--- 
a/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/JUnit46StackTraceWriter.java
+++ 
b/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/JUnit46StackTraceWriter.java
@@ -19,9 +19,7 @@ package org.apache.maven.surefire.common.junit48;
  * under the License.
  */
 
-import org.apache.maven.surefire.common.junit4.JUnit4RunListener;
 import org.apache.maven.surefire.common.junit4.JUnit4StackTraceWriter;
-
 import org.junit.runner.notification.Failure;
 
 /**
@@ -50,6 +48,11 @@ public class JUnit46StackTraceWriter
 
     protected final String getTestClassName()
     {
-        return JUnit4RunListener.extractClassName( 
junitFailure.getDescription() );
+        return junitFailure.getDescription().getClassName();
+    }
+
+    protected String getTestMethodName()
+    {
+        return junitFailure.getDescription().getMethodName();
     }
 }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/d9b577cd/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreRunListener.java
----------------------------------------------------------------------
diff --git 
a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreRunListener.java
 
b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreRunListener.java
index 5d76c39..81e4f80 100644
--- 
a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreRunListener.java
+++ 
b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreRunListener.java
@@ -87,17 +87,17 @@ public class JUnitCoreRunListener
             }
             else
             {
-                if ( item.getMethodName() != null )
+                if ( extractDescriptionMethodName( item ) != null )
                 {
                     testSet.incrementTestMethodCount();
                     if ( itemTestClassName == null )
                     {
-                        itemTestClassName = item.getClassName();
+                        itemTestClassName = extractDescriptionClassName( item 
);
                     }
                 }
                 else
                 {
-                    classMethodCounts.put( item.getClassName(), new TestSet( 
item ) );
+                    classMethodCounts.put( extractDescriptionClassName( item 
), new TestSet( item ) );
                 }
             }
         }
@@ -112,4 +112,16 @@ public class JUnitCoreRunListener
     {
         return new JUnit46StackTraceWriter( failure );
     }
+
+    @Override
+    protected String extractDescriptionClassName( Description description )
+    {
+        return description.getClassName();
+    }
+
+    @Override
+    protected String extractDescriptionMethodName( Description description )
+    {
+        return description.getMethodName();
+    }
 }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/d9b577cd/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/NonConcurrentRunListener.java
----------------------------------------------------------------------
diff --git 
a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/NonConcurrentRunListener.java
 
b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/NonConcurrentRunListener.java
index 9d4e9c1..539fd73 100644
--- 
a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/NonConcurrentRunListener.java
+++ 
b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/NonConcurrentRunListener.java
@@ -37,7 +37,6 @@ public class NonConcurrentRunListener
     extends JUnit4RunListener
     implements ConsoleOutputReceiver
 {
-
     private Description currentTestSetDescription;
 
     private Description lastFinishedDescription;
@@ -56,12 +55,25 @@ public class NonConcurrentRunListener
 
     protected SimpleReportEntry createReportEntry( Description description )
     {
-        return new SimpleReportEntry( description.getClassName(), 
description.getDisplayName() );
+        return new SimpleReportEntry( extractDescriptionClassName( description 
), description.getDisplayName() );
     }
 
     protected SimpleReportEntry createReportEntryForTestSet( Description 
description )
     {
-        return new SimpleReportEntry( description.getClassName(), 
description.getClassName() );
+        String testClassName = extractDescriptionClassName( description );
+        return new SimpleReportEntry( testClassName, testClassName );
+    }
+
+    @Override
+    protected String extractDescriptionClassName( Description description )
+    {
+        return description.getClassName();
+    }
+
+    @Override
+    protected String extractDescriptionMethodName( Description description )
+    {
+        return description.getMethodName();
     }
 
     @Override
@@ -110,7 +122,7 @@ public class NonConcurrentRunListener
         throws Exception
     {
         super.testFinished( description );
-        this.lastFinishedDescription = description;
+        lastFinishedDescription = description;
     }
 
     @Override
@@ -120,7 +132,7 @@ public class NonConcurrentRunListener
         finishLastTestSetIfNecessary( description );
 
         super.testIgnored( description );
-        this.lastFinishedDescription = description;
+        lastFinishedDescription = description;
     }
 
     @Override
@@ -130,14 +142,14 @@ public class NonConcurrentRunListener
         finishLastTestSetIfNecessary( failure.getDescription() );
 
         super.testFailure( failure );
-        this.lastFinishedDescription = failure.getDescription();
+        lastFinishedDescription = failure.getDescription();
     }
 
     @Override
     public void testAssumptionFailure( Failure failure )
     {
         super.testAssumptionFailure( failure );
-        this.lastFinishedDescription = failure.getDescription();
+        lastFinishedDescription = failure.getDescription();
     }
 
     @Override

Reply via email to