-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Add test count to JUnit reporter #6319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Generated by 🚫 Danger |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @nandhinisubbu! Just one small improvement ...
| static func generateReport(_ violations: [StyleViolation]) -> String { | ||
| let warningCount = violations.filter({ $0.severity == .warning }).count | ||
| let errorCount = violations.filter({ $0.severity == .error }).count | ||
| let testCount = violations.count |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| let testCount = violations.count | |
| let testCount = warningCount + errorCount |
So separate issues always add up to the total number.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SimplyDanny, Does it mean, only the count of tests with severity as .warning and .error to be considered for tests count?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The JUnit reporter is a bit strange, because JUnit is actually a testing framework. We run tests in it and they either succeed or fail (or get skipped).
Now to support this format, we need to interpret SwiftLint results as kind of tests. But we only have tests that fail. So the total number of tests is comprised by the number of issues we report, and those are either warnings or errors.
That said, violations.count is totally fine as well. Adding warnings and errors makes clearer, though, that the reporter numbers are consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the clarification @SimplyDanny!, have pushed the changes.
Enhancement - #6161