Skip to content

Commit

Permalink
[SUREFIRE-2232] [REGRESSION] StatelessXmlReporter fails to process fa…
Browse files Browse the repository at this point in the history
…iled result without a throwable

This closes #716
  • Loading branch information
dr29bart authored and michael-o committed Jun 11, 2024
1 parent 57b7837 commit e6287dd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import static org.apache.maven.plugin.surefire.report.ReportEntryType.SKIPPED;
import static org.apache.maven.plugin.surefire.report.ReportEntryType.SUCCESS;
import static org.apache.maven.surefire.shared.utils.StringUtils.isBlank;
import static org.apache.maven.surefire.shared.utils.StringUtils.isNotBlank;

// CHECKSTYLE_OFF: LineLength
/**
Expand Down Expand Up @@ -451,7 +452,9 @@ private static void getTestProblems(
String type = delimiter == -1 ? stackTrace : stackTrace.substring(0, delimiter);
ppw.addAttribute("type", type);
} else {
ppw.addAttribute("type", new StringTokenizer(stackTrace).nextToken());
if (isNotBlank(stackTrace)) {
ppw.addAttribute("type", new StringTokenizer(stackTrace).nextToken());
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,23 @@ public void testSyncOnDeferredFile() throws Exception {
assertThat((boolean) getInternalState(out, "closed")).isTrue();
}

public void testReporterHandlesATestWithoutMessageAndWithEmptyStackTrace() {
StackTraceWriter stackTraceWriterOne = new DeserializedStacktraceWriter(null, null, "");

WrappedReportEntry testReport = new WrappedReportEntry(
new SimpleReportEntry(
NORMAL_RUN, 1L, getClass().getName(), null, "a test name", null, stackTraceWriterOne, 5),
ERROR,
5,
null,
null);

StatelessXmlReporter reporter = new StatelessXmlReporter(
reportDir, null, false, 1, new HashMap<>(), XSD, "3.0.1", false, false, false, false);

reporter.testSetCompleted(testReport, stats);
}

private boolean defaultCharsetSupportsSpecialChar() {
// some charsets are not able to deal with \u0115 on both ways of the conversion
return "\u0115\u00DC".equals(new String("\u0115\u00DC".getBytes()));
Expand Down

0 comments on commit e6287dd

Please sign in to comment.