Bug 63827

Summary: LegacyXmlResultFormatter of JUnitLauncher Task does not write StackTrace of failure
Product: Ant Reporter: Michael Seele <mseele>
Component: Optional TasksAssignee: Ant Notifications List <notifications>
Status: RESOLVED FIXED    
Severity: major    
Priority: P2    
Version: 1.10.7   
Target Milestone: 1.10.8   
Hardware: PC   
OS: All   
Attachments: Patch which adds Stacktrace to failures & abortions (without filtering the stacktrace)

Description Michael Seele 2019-10-10 07:22:36 UTC
Switching from JUnit 4 to JUnit 5 we detected that LegacyXmlResultFormatter does not write the StackTrace of a failure into the xml. Only the message is stored.
Which makes troubleshooting very hard on failed tests.

Please see JUnit 5 code here:
https://github.com/apache/ant/blob/26b8a01e6421d22a2ca4393ab1420444b07a0bfd/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/LegacyXmlResultFormatter.java#L279

This is how the JUnit 4 code does it:
https://github.com/apache/ant/blob/3a4980e3c4be56745964442abc01360b618e3a85/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLJUnitResultFormatter.java#L316

final String strace = JUnitTestRunner.getFilteredTrace(t);
final Text trace = doc.createTextNode(strace);
nested.appendChild(trace);

These tree lines are missing in LegacyXmlResultFormatter for JUnit5.

I can add a patch for this if desired!?
Comment 1 Michael Seele 2019-10-10 08:30:36 UTC
Created attachment 36816 [details]
Patch which adds Stacktrace to failures & abortions (without filtering the stacktrace)
Comment 2 Jaikiran Pai 2019-10-10 08:49:43 UTC
Hello mseele, I actually pushed a commit a few minutes before I saw you upload this patch. I see that I missed the "aborted" section. I have now pushed another commit to fix that too. Thank you for reporting this issue as well as taking time to create a patch.
Comment 3 Michael Seele 2019-10-10 08:53:12 UTC
Great :)

Just one question, why using "cause.get()" when "t" is already a final variable (of "cause.get()")?
Comment 4 Jaikiran Pai 2019-10-10 08:56:21 UTC
> Just one question, why using "cause.get()" when "t" is already a final variable (of "cause.get()")?

Because working on too many unrelated things and not focusing enough for a "simple fix" :) You are right though, we can just use "t" there. I'll probably get to it later.