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 2022/02/06 08:11:25 UTC

[GitHub] [maven-surefire] sman-81 commented on a change in pull request #457: [SUREFIRE-1992] Do not output class name on error/failure for certain exceptions

sman-81 commented on a change in pull request #457:
URL: https://github.com/apache/maven-surefire/pull/457#discussion_r800143609



##########
File path: surefire-api/src/main/java/org/apache/maven/surefire/api/report/LegacyPojoStackTraceWriter.java
##########
@@ -81,19 +80,26 @@ public String smartTrimmedStackTrace()
         result.append( "#" );
         result.append( testMethod );
         SafeThrowable throwable = getThrowable();
-        if ( throwable.getTarget() instanceof AssertionError )
-        {
-            result.append( " " );
-            result.append( getTruncatedMessage( throwable.getMessage(), MAX_LINE_LENGTH - result.length() ) );
-        }
-        else
+        Throwable target = throwable.getTarget();
+
+        if ( target != null )
         {
-            Throwable target = throwable.getTarget();
-            if ( target != null )
+
+            final String excClassName = target.getClass().getName();
+
+            if ( ! ( AssertionError.class.isInstance( target )
+                    || excClassName.endsWith( ".AssertionFailedError" )
+                    || excClassName.endsWith( ".ComparisonFailure" )
+                    || excClassName.startsWith( "org.opentest4j." ) ) )
+            {
+                result.append( ' ' )
+                      .append( target.getClass().getSimpleName() );
+            }
+            final String msg = throwable.getMessage();
+            if ( isNotEmpty( msg ) )
             {
-                result.append( " " );
-                result.append( target.getClass().getSimpleName() );
-                result.append( getTruncatedMessage( throwable.getMessage(), MAX_LINE_LENGTH - result.length() ) );
+                result.append( ' ' )
+                      .append( msg.split( "\r?\n" )[0] );

Review comment:
       Hi @Tibor17
   
   > I know that the `.split( "\r?\n" )[0]` was my request but this part of code will break the nackwards compatibility.
   
   In what way would this break backward compatibility?
   
   Surefire has always kept each failure on one line on the output. This behaviour is still true.
   
   If your concern is that important info is contained on lines 2..n of the error/failure message, we could replace line separators by space and keep the complete message.
   ```suggestion
                         .append( msg.replaceAll( "\r?\n", " " ) );
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org