Skip to content

Commit

Permalink
[SUREFIRE-2219] Add test stdErr/stdOut output to ReportTestCase
Browse files Browse the repository at this point in the history
TestSuiteXmlParser no longer ignores the 'system-out' and 'system-err'
tags from the Surefire report XML. It parses them and sets the
corresponding properties in ReportTestCase.
  • Loading branch information
kriegaex committed Dec 4, 2023
1 parent aa864f4 commit 6d59ba1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public final class ReportTestCase {
private String failureErrorLine;

private String failureDetail;
private String systemOut;
private String systemErr;

private boolean hasFailure;

Expand Down Expand Up @@ -138,6 +140,24 @@ public ReportTestCase setError(String message, String type) {
return setFailureMessage(message).setFailureType(type);
}

public String getSystemOut() {
return systemOut;
}

public ReportTestCase setSystemOut(String message) {
systemOut = message;
return this;
}

public String getSystemErr() {
return systemErr;
}

public ReportTestCase setSystemErr(String message) {
systemErr = message;
return this;
}

public ReportTestCase setSkipped(String message) {
hasFailure = false;
hasError = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,18 @@ public void startElement(String uri, String localName, String qName, Attributes
break;
case "failure":
currentElement = new StringBuilder();

testCase.setFailure(attributes.getValue("message"), attributes.getValue("type"));
currentSuite.incrementNumberOfFailures();
break;
case "error":
currentElement = new StringBuilder();

testCase.setError(attributes.getValue("message"), attributes.getValue("type"));
currentSuite.incrementNumberOfErrors();
break;
case "system-out":
case "system-err":
currentElement = new StringBuilder();
break;
case "skipped":
String message = attributes.getValue("message");
testCase.setSkipped(message != null ? message : "skipped");
Expand Down Expand Up @@ -203,7 +205,13 @@ public void endElement(String uri, String localName, String qName) throws SAXExc
case "failure":
case "error":
testCase.setFailureDetail(currentElement.toString())
.setFailureErrorLine(parseErrorLine(currentElement, testCase.getFullClassName()));
.setFailureErrorLine(parseErrorLine(currentElement, testCase.getFullClassName()));
break;
case "system-out":
testCase.setSystemOut(currentElement.toString());
break;
case "system-err":
testCase.setSystemErr(currentElement.toString());
break;
case "time":
try {
Expand Down

0 comments on commit 6d59ba1

Please sign in to comment.