marcphilipp commented on code in PR #702:
URL: https://github.com/apache/maven-surefire/pull/702#discussion_r1440135518


##########
maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java:
##########
@@ -456,21 +456,13 @@ private static void getTestProblems(
             }
         }
 
-        boolean hasNestedElements = createOutErrElementsInside & stackTrace != 
null;
-
-        if (stackTrace != null) {
-            if (hasNestedElements) {
-                ppw.startElement("stackTrace");
+        if (enableNestedOutErrElements) {
+            ppw.startElement("stackTrace");
+            if (stackTrace != null) {
+                extraEscapeElementValue(stackTrace, outputStreamWriter, ppw, 
fw);
             }
+            ppw.endElement();
 
-            extraEscapeElementValue(stackTrace, outputStreamWriter, ppw, fw);

Review Comment:
   Yes, that's right.
   
   ## Before (with 3.2.3 and earlier)
   ```xml
   <testcase name="addsTwoNumbers" 
classname="com.example.project.CalculatorTests" time="0.014">
     <failure message="1 + 1 should equal 2 ==&gt; expected: &lt;3&gt; but was: 
&lt;2&gt;" 
type="org.opentest4j.AssertionFailedError"><![CDATA[org.opentest4j.AssertionFailedError:
 1 + 1 should equal 2 ==> expected: <3> but was: <2>
     at 
org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
     at 
org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
     at org.junit.jupiter.api.AssertEquals.failNotEqual(AssertEquals.java:197)
     at org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:150)
     at org.junit.jupiter.api.Assertions.assertEquals(Assertions.java:563)
     at 
com.example.project.CalculatorTests.addsTwoNumbers(CalculatorTests.java:26)
     at java.base/java.lang.reflect.Method.invoke(Method.java:578)
     at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
     at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
   ]]></failure>
   </testcase>
   ```
   
   ## After this change
   ```xml
   <testcase name="addsTwoNumbers" 
classname="com.example.project.CalculatorTests" time="0.014">
     <failure message="1 + 1 should equal 2 ==&gt; expected: &lt;3&gt; but was: 
&lt;2&gt;" type="org.opentest4j.AssertionFailedError"/>
   </testcase>
   ```



-- 
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-unsubscr...@maven.apache.org

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

Reply via email to