sman-81 commented on a change in pull request #457:
URL: https://github.com/apache/maven-surefire/pull/457#discussion_r800176861
##########
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:
> The point of the issue is to remove the function which takes first 77
chars, right?
Correct.
Or to put in more general terms: output enough of the error message that it
is always clear and eases troubleshooting.
Your suggestion to print only the first line is a good compromise I think.
To have multi-line messages in exception is unusual (if not an
anti-pattern). I cannot think of many examples other than jdbc drivers maybe
that tend to be quite verbose in the exception message.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]