Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions outputs/junit.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,18 @@ func (r JUnit) Output(w io.Writer, results <-chan []resource.TestResult,
endTime = testResult.EndTime
}
duration := strconv.FormatFloat(testResult.Duration.Seconds(), 'f', 3, 64)
summary[testCount] = "<testcase name=\"" +
testResult.ResourceType + " " +
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?

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,

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

}
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),

duration,
);

if testResult.Result == resource.FAIL {
summary[testCount] += "<system-err>" +
escapeString(humanizeResult(testResult, true, includeRaw)) +
Expand Down