Skip to content

Bugfix/add skipped to test output - #838

Merged
quintush merged 6 commits into
mainfrom
bugfix/AddSkippedToTestOutput
Apr 25, 2026
Merged

quintush merged 6 commits into
mainfrom
bugfix/AddSkippedToTestOutput

Conversation

@quintush

@quintush quintush commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Add skipped tests to test output formats, including tests.

Copilot AI review requested due to automatic review settings April 7, 2026 19:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for reporting skipped tests across the project’s test output formats (JUnit, NUnit, XUnit, Sonar), and updates the formatter test suites accordingly.

Changes:

  • Include skipped test information in TestJobResult.Stringify() and assertion stringification.
  • Add skipped handling (counts + reason/message) to XML formatters (JUnit/NUnit/XUnit/Sonar).
  • Extend formatter unit tests to validate skipped test serialization.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
pkg/unittest/results/test_job_result.go Adds skipped header to stringified test output.
pkg/unittest/results/assertion_result.go Updates assertion stringification and introduces skipped-path formatting.
pkg/unittest/formatter/xunit_report_xml.go Adds skipped test counting and <reason> output for XUnit XML.
pkg/unittest/formatter/xunit_report_xml_test.go Updates XUnit tests to cover skipped cases.
pkg/unittest/formatter/sonar_report_xml.go Adds <skipped> element emission for Sonar XML.
pkg/unittest/formatter/sonar_report_xml_test.go Updates Sonar tests and adds skipped coverage.
pkg/unittest/formatter/nunit_report_xml.go Adds skipped counting and <reason> output for NUnit XML.
pkg/unittest/formatter/nunit_report_xml_test.go Updates NUnit tests and adds skipped coverage.
pkg/unittest/formatter/junit_report_xml.go Adds <skipped> message emission for JUnit XML.
pkg/unittest/formatter/junit_report_xml_test.go Updates JUnit tests and adds skipped coverage.
pkg/unittest/formatter/formatter_test.go Extends test helpers to create skipped jobs/assertions.
Comments suppressed due to low confidence (1)

pkg/unittest/formatter/nunit_report_xml.go:144

  • totalSuccess is declared and updated but never read. In Go this causes a compile error (unused variable). Remove it, or reintroduce its use in the generated report if it was meant to drive an attribute/value.
	totalTests := 0
	totalErrors := 0
	totalFailures := 0
	totalSkipped := 0
	totalSuccess := true
	testSuites := []NUnitTestSuite{}

	// convert TestSuiteResults to NUnit test suites
	for _, testSuiteResult := range testSuiteResults {
		totalSuccess = totalSuccess && testSuiteResult.Passed


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/unittest/results/assertion_result.go
Comment thread pkg/unittest/formatter/junit_report_xml.go
Comment on lines +119 to +125
if expected[i].Reason != nil || actual[i].Reason != nil {
assert.Equal(expected[i].Reason.Reason, actual[i].Reason.Reason)
assert.Equal(expected[i].Result, actual[i].Result)
} else {
// Verify if both are nil, otherwise it's still a failure.
assert.True(expected[i].Reason == nil && actual[i].Reason == nil)
}

Copilot AI Apr 7, 2026

Copy link

Choose a reason for hiding this comment

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

The Reason comparison uses expected[i].Reason != nil || actual[i].Reason != nil and then dereferences both pointers. If one side is nil, this will panic and mask the assertion failure. Use an && check (both non-nil) and keep the nil-equality assertion in the else branch.

Copilot uses AI. Check for mistakes.
Comment on lines +99 to +105
if expected[i].Reason != nil || actual[i].Reason != nil {
assert.Equal(expected[i].Reason.Message, actual[i].Reason.Message)
assert.Equal(expected[i].Result, actual[i].Result)
} else {
// Verify if both are nil, otherwise it's still a failure.
assert.True(expected[i].Reason == nil && actual[i].Reason == nil)
}

Copilot AI Apr 7, 2026

Copy link

Choose a reason for hiding this comment

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

The Reason comparison uses expected[i].Reason != nil || actual[i].Reason != nil and then dereferences both. If only one is nil, this will panic instead of producing a clear test failure. Use an && check (both non-nil) and otherwise assert both are nil.

Copilot uses AI. Check for mistakes.
Comment thread pkg/unittest/formatter/sonar_report_xml_test.go
Comment thread pkg/unittest/formatter/junit_report_xml_test.go

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated 6 comments.

Comments suppressed due to low confidence (1)

pkg/unittest/formatter/nunit_report_xml.go:145

  • totalSuccess is still computed/updated but no longer used in the generated NUnit XML after the createNUnitTestResults signature change. This makes the control flow misleading and suggests a missing output field; consider removing totalSuccess (and the totalSuccess = totalSuccess && ... line) or wiring it back into the XML if it’s still needed.
	totalSuccess := true
	testSuites := []NUnitTestSuite{}

	// convert TestSuiteResults to NUnit test suites
	for _, testSuiteResult := range testSuiteResults {
		totalSuccess = totalSuccess && testSuiteResult.Passed

		ts := n.createNUnitTestSuite(testSuiteResult)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/unittest/test_job.go
Comment thread pkg/unittest/results/test_job_result.go Outdated
return content.String()
}

// Stringify to xml attribute, replacing the the object to a customized formatted string.

Copilot AI Apr 25, 2026

Copy link

Choose a reason for hiding this comment

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

Comment has a duplicated word: "replacing the the object". Please correct it for readability.

Suggested change
// Stringify to xml attribute, replacing the the object to a customized formatted string.
// Stringify to xml attribute, replacing the object to a customized formatted string.

Copilot uses AI. Check for mistakes.
Comment thread pkg/unittest/formatter/junit_report_xml_test.go
Comment thread .github/workflows/codeql.yml Outdated
Comment on lines 45 to 46
uses: github/codeql-action/init@c10b8064de6f491fea524254123dbe5e09572f13 #v4.35.1
with:

Copilot AI Apr 25, 2026

Copy link

Choose a reason for hiding this comment

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

The version comments use #v4.35.1 (missing a space after #), which is inconsistent with other version comments in the workflows that use # vX.Y.Z. Consider normalizing for consistency/readability.

Copilot uses AI. Check for mistakes.
Comment thread .github/workflows/go.yml Outdated

- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@5d4e8d1aca955e8d8589aabd499c5cae939e33c7 # v4.31.9
uses: github/codeql-action/upload-sarif@c10b8064de6f491fea524254123dbe5e09572f13 #v4.35.1

Copilot AI Apr 25, 2026

Copy link

Choose a reason for hiding this comment

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

Version comment is #v4.35.1 (missing a space after #), inconsistent with other workflow version comments (e.g. # v6.0.2). Consider using # v4.35.1 for consistency.

Suggested change
uses: github/codeql-action/upload-sarif@c10b8064de6f491fea524254123dbe5e09572f13 #v4.35.1
uses: github/codeql-action/upload-sarif@c10b8064de6f491fea524254123dbe5e09572f13 # v4.35.1

Copilot uses AI. Check for mistakes.
Comment thread .github/workflows/scorecards.yml Outdated
# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@5d4e8d1aca955e8d8589aabd499c5cae939e33c7 # v4.31.9
uses: github/codeql-action/upload-sarif@c10b8064de6f491fea524254123dbe5e09572f13 #v4.35.1

Copilot AI Apr 25, 2026

Copy link

Choose a reason for hiding this comment

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

Version comment is #v4.35.1 (missing a space after #), inconsistent with other workflow version comments (e.g. # v6.0.2). Consider using # v4.35.1 for consistency.

Suggested change
uses: github/codeql-action/upload-sarif@c10b8064de6f491fea524254123dbe5e09572f13 #v4.35.1
uses: github/codeql-action/upload-sarif@c10b8064de6f491fea524254123dbe5e09572f13 # v4.35.1

Copilot uses AI. Check for mistakes.
@sonarqubecloud

Copy link
Copy Markdown

@quintush
quintush merged commit c7c5305 into main Apr 25, 2026
10 checks passed
@quintush quintush linked an issue Apr 30, 2026 that may be closed by this pull request
@quintush
quintush deleted the bugfix/AddSkippedToTestOutput branch May 27, 2026 07:54
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.

Skipped tests appear as Failed in any output format

2 participants