You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2018/12/15 13:05:22 UTC

[GitHub] eolivelli commented on a change in pull request #211: Added more unit tests in SmartStackTraceParserTest and refactoring of SmartStackTraceParser

eolivelli commented on a change in pull request #211: Added more unit tests in SmartStackTraceParserTest and refactoring of SmartStackTraceParser
URL: https://github.com/apache/maven-surefire/pull/211#discussion_r241949129
 
 

 ##########
 File path: surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/SmartStackTraceParser.java
 ##########
 @@ -103,64 +97,62 @@ public String getString()
         }
         else
         {
-            for ( int i = 0; i < stackTraceElements.size(); i++ )
+            for ( int i = 0, size = stackTraceElements.size(); i < size; i++ )
             {
                 final StackTraceElement stackTraceElement = stackTraceElements.get( i );
+                final boolean isTestClassName = stackTraceElement.getClassName().equals( testClassName );
                 if ( i == 0 )
                 {
-                    result.append( simpleName );
-                    if ( !stackTraceElement.getClassName().equals( testClassName ) )
-                    {
-                        result.append( ">" );
-                    }
-                    else
-                    {
-                        result.append( "." );
-                    }
+                    result.append( testClassSimpleName )
+                            .append( isTestClassName ? '.' : '>' );
                 }
-                if ( !stackTraceElement.getClassName().equals( testClassName ) )
+
+                if ( !isTestClassName )
                 {
-                    result.append( getSimpleName( stackTraceElement.getClassName() ) ) // Add the name of the superclas
-                        .append( "." );
+                    result.append( toSimpleClassName( stackTraceElement.getClassName() ) )
+                        .append( '.' );
                 }
+
                 result.append( stackTraceElement.getMethodName() )
-                    .append( ":" )
+                    .append( ':' )
                     .append( stackTraceElement.getLineNumber() )
                     .append( "->" );
             }
 
             if ( result.length() >= 2 )
             {
-                result.deleteCharAt( result.length() - 1 )
-                    .deleteCharAt( result.length() - 1 );
+                result.setLength( result.length() - 2 );
             }
         }
 
-        Throwable target = throwable.getTarget();
-        String exception = target.getClass().getName();
+        final Throwable target = throwable.getTarget();
+        final Class<?> excType = target.getClass();
+        final String excClassName = excType.getName();
+        final String msg = throwable.getMessage();
+
         if ( target instanceof AssertionError
-            || "junit.framework.AssertionFailedError".equals( exception )
-            || "junit.framework.ComparisonFailure".equals( exception ) )
+                || "junit.framework.AssertionFailedError".equals( excClassName )
 
 Review comment:
   This is some junit 4 plumbing.
   Do we need something similar for junit5 ?
   
   @sormuras

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services