[
https://issues.apache.org/jira/browse/SUREFIRE-2224?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17802035#comment-17802035
]
ASF GitHub Bot commented on SUREFIRE-2224:
------------------------------------------
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 ==> expected: <3> but was:
<2>"
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 ==> expected: <3> but was:
<2>" type="org.opentest4j.AssertionFailedError"/>
</testcase>
```
> StatelessXmlReporter#getTestProblems() does not properly reflect report
> schema structure
> ----------------------------------------------------------------------------------------
>
> Key: SUREFIRE-2224
> URL: https://issues.apache.org/jira/browse/SUREFIRE-2224
> Project: Maven Surefire
> Issue Type: Bug
> Components: xml generation
> Affects Versions: 3.2.3
> Reporter: Michael Osipov
> Assignee: Michael Osipov
> Priority: Major
> Fix For: 3.2.4
>
>
> According to
> https://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report.xsd
> and
> https://maven.apache.org/surefire/maven-failsafe-plugin/xsd/failsafe-test-report.xsd
> not all nested elements contain {{stackTrace}}, {{system-out}} and
> {{system-err}} elements, but the code makes it conditional whether there is a
> stack trace or not. This does not comply with the schema definition. Either
> the nested element is simple content or complex. In the latter {{stackTrace}}
> is mandatory, even if there is no strack trace according to the schema. The
> system streams are optional.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)