Repository navigation
Bugfix/add skipped to test output - #838
Conversation
There was a problem hiding this comment.
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
totalSuccessis 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.
| 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) | ||
| } |
There was a problem hiding this comment.
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.
| 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) | ||
| } |
There was a problem hiding this comment.
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.
…ctions on xml output, including tests.
There was a problem hiding this comment.
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
totalSuccessis still computed/updated but no longer used in the generated NUnit XML after thecreateNUnitTestResultssignature change. This makes the control flow misleading and suggests a missing output field; consider removingtotalSuccess(and thetotalSuccess = 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.
| return content.String() | ||
| } | ||
|
|
||
| // Stringify to xml attribute, replacing the the object to a customized formatted string. |
There was a problem hiding this comment.
Comment has a duplicated word: "replacing the the object". Please correct it for readability.
| // 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. |
| uses: github/codeql-action/init@c10b8064de6f491fea524254123dbe5e09572f13 #v4.35.1 | ||
| with: |
There was a problem hiding this comment.
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.
|
|
||
| - 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 |
There was a problem hiding this comment.
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.
| uses: github/codeql-action/upload-sarif@c10b8064de6f491fea524254123dbe5e09572f13 #v4.35.1 | |
| uses: github/codeql-action/upload-sarif@c10b8064de6f491fea524254123dbe5e09572f13 # v4.35.1 |
| # 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 |
There was a problem hiding this comment.
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.
| uses: github/codeql-action/upload-sarif@c10b8064de6f491fea524254123dbe5e09572f13 #v4.35.1 | |
| uses: github/codeql-action/upload-sarif@c10b8064de6f491fea524254123dbe5e09572f13 # v4.35.1 |
|



Add skipped tests to test output formats, including tests.