Skip to content

Fix #962 - use the title for the jUnit test case name - #1035

Open
manarth wants to merge 3 commits into
goss-org:masterfrom
manarth:issue-962
Open

Fix #962 - use the title for the jUnit test case name#1035
manarth wants to merge 3 commits into
goss-org:masterfrom
manarth:issue-962

Conversation

@manarth

@manarth manarth commented Sep 6, 2025

Copy link
Copy Markdown

Description of change

Fix #962
This checks for the presence of a "title" attribute on the test-case, and uses that in the jUnit report if it is present.

Checklist
  • make test-all (UNIX) passes. CI will also test this
  • unit and/or integration tests are included (if applicable)
  • documentation is changed or added (if applicable)

@manarth
manarth requested a review from aelsabbahy as a code owner September 6, 2025 12:15

@kgaughan kgaughan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some suggestions. Also, could you merge from master and run the test suite to make sure there are no issues this change might cause?

Comment thread outputs/junit.go
escapeString(testResult.ResourceId) + " " +
testResult.Property + "\" " +
"time=\"" + duration + "\">\n"
testcaseName := fmt.Sprintf("%s %s %s",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like you're mixing spaces and tabs, and have a number of unnecessary semicolons. Could you run go fmt over the file?

Comment thread outputs/junit.go
"time=\"" + duration + "\">\n"
testcaseName := fmt.Sprintf("%s %s %s",
testResult.ResourceType,
escapeString(testResult.ResourceId),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could instead just escape once when building <testcase>.

Suggested change
escapeString(testResult.ResourceId),
testResult.ResourceId,

Comment thread outputs/junit.go
escapeString(testResult.ResourceId),
testResult.Property);
if (testResult.Title != "") {
testcaseName = escapeString(testResult.Title);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
testcaseName = escapeString(testResult.Title);
testcaseName = testResult.Title

Comment thread outputs/junit.go
testcaseName = escapeString(testResult.Title);
}
summary[testCount] = fmt.Sprintf("<testcase name=\"%s\" time=\"%s\">\n",
testcaseName,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
testcaseName,
escapeString(testcaseName),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JUNIT Test Report Generation - XML ​​File Improvement

2 participants