Skip to content

Commit

Permalink
[SUREFIRE-2257] [REGRESSION] NPEx: Cannot invoke "Object.toString()" …
Browse files Browse the repository at this point in the history
…because "value" is null

This closes #774
  • Loading branch information
michael-o committed Aug 28, 2024
1 parent e99f11e commit 69c1b46
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,14 @@ private void renderSectionPackages() {
});

for (Map.Entry<String, List<ReportTestSuite>> entry : suitePackages.entrySet()) {
String packageName = entry.getKey();
String packageName = !entry.getKey().isEmpty() ? entry.getKey() : "(default package)";

List<ReportTestSuite> testSuiteList = entry.getValue();

Map<String, Object> packageSummary = parser.getSummary(testSuiteList);

tableRow(new String[] {
createLinkPatternedText(packageName, '#' + packageName),
createLinkPatternedText(packageName, '#' + DoxiaUtils.encodeId(packageName)),
String.valueOf(packageSummary.get("totalTests")),
String.valueOf(packageSummary.get("totalErrors")),
String.valueOf(packageSummary.get("totalFailures")),
Expand All @@ -213,7 +213,7 @@ private void renderSectionPackages() {
paragraph(getI18nString("surefire", "text.note2"));

for (Map.Entry<String, List<ReportTestSuite>> entry : suitePackages.entrySet()) {
String packageName = entry.getKey();
String packageName = !entry.getKey().isEmpty() ? entry.getKey() : "(default package)";

List<ReportTestSuite> testSuiteList = entry.getValue();

Expand Down Expand Up @@ -265,7 +265,7 @@ private void renderSectionTestSuite(ReportTestSuite suite) {

sink.tableCell();

sink.link("#" + suite.getPackageName() + '.' + suite.getName());
sink.link("#" + suite.getFullClassName());

if (suite.getNumberOfErrors() > 0) {
sinkIcon("error");
Expand All @@ -281,7 +281,7 @@ private void renderSectionTestSuite(ReportTestSuite suite) {

sink.tableCell_();

tableCell(createLinkPatternedText(suite.getName(), '#' + suite.getPackageName() + '.' + suite.getName()));
tableCell(createLinkPatternedText(suite.getName(), '#' + suite.getFullClassName()));

tableCell(Integer.toString(suite.getNumberOfTests()));

Expand Down Expand Up @@ -314,7 +314,7 @@ private void renderSectionTestCases() {
List<ReportTestCase> testCases = suite.getTestCases();

if (!testCases.isEmpty()) {
startSection(suite.getName(), suite.getPackageName() + '.' + suite.getName());
startSection(suite.getName(), suite.getFullClassName());

boolean showTable = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ public ReportTestSuite setFullClassName(String fullClassName) {
this.fullClassName = fullClassName;
int lastDotPosition = fullClassName.lastIndexOf(".");
name = fullClassName.substring(lastDotPosition + 1, fullClassName.length());
// For the default package we will set an empty string instead of null because otherwise
// the package name cannot be used as a map key.
packageName = lastDotPosition == -1 ? "" : fullClassName.substring(0, lastDotPosition);
return this;
}
Expand Down

0 comments on commit 69c1b46

Please sign in to comment.