Skip to content
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

[Fix #9780] Support summary report for JUnitFormatter #9781

Merged

Conversation

koic
Copy link
Member

@koic koic commented May 6, 2021

Fixes #9780.

This PR supports summary report for JUnitFormatter.

It adds the following attributes to the <testsuite> element.

  • tests attribute ... Inspected file count.
  • failures attribute ... Total offense count.

This is a JUnit format example:

% rubocop -f junit --display-only-failed lib/rubocop/formatter/junit_formatter.rb
<?xml version='1.0'?>
<testsuites>
  <testsuite name='rubocop' tests='1' failures='2'>
    <testcase classname='lib.rubocop.formatter.junit_formatter' name='Layout/LineLength'>
      <failure type='Layout/LineLength' message='Layout/LineLength: Line is too long. [110/100]'>
        /Users/koic/src/github.com/rubocop/rubocop/lib/rubocop/formatter/junit_formatter.rb:65:101
      </failure>
    </testcase>
    <testcase classname='lib.rubocop.formatter.junit_formatter' name='Metrics/AbcSize'>
      <failure type='Metrics/AbcSize' message='Metrics/AbcSize:
Assignment Branch Condition size for file_finished is too high. [&lt;8, 16, 2&gt; 18/17]'>
        /Users/koic/src/github.com/rubocop/rubocop/lib/rubocop/formatter/junit_formatter.rb:29:7
      </failure>
    </testcase>
  </testsuite>
</testsuites>

These mean the values of 1 file inspected and 2 offenses detected below.

% rubocop lib/rubocop/formatter/junit_formatter.rb
Inspecting 1 file
(snip)

1 file inspected, 2 offenses detected, 2 offenses auto-correctable

Before submitting the PR make sure the following are checked:

  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Ran bundle exec rake default. It executes all tests and runs RuboCop on its own code.
  • Added an entry (file) to the changelog folder named {change_type}_{change_description}.md if the new code introduces user-observable changes. See changelog entry format for details.

Fixes rubocop#9780.

This PR supports summary report for `JUnitFormatter`.

It adds the following attributes to the `<testsuite>` element.

- `tests` attribute ... Inspected file count.
- `failures` attribute ... Total offense count.

This is a JUnit format example:

```xml
% rubocop -f junit --display-only-failed lib/rubocop/formatter/junit_formatter.rb
<?xml version='1.0'?>
<testsuites>
  <testsuite name='rubocop' tests='1' failures='2'>
    <testcase classname='lib.rubocop.formatter.junit_formatter' name='Layout/LineLength'>
      <failure type='Layout/LineLength' message='Layout/LineLength: Line is too long. [110/100]'>
        /Users/koic/src/github.com/rubocop/rubocop/lib/rubocop/formatter/junit_formatter.rb:65:101
      </failure>
    </testcase>
    <testcase classname='lib.rubocop.formatter.junit_formatter' name='Metrics/AbcSize'>
      <failure type='Metrics/AbcSize' message='Metrics/AbcSize:
Assignment Branch Condition size for file_finished is too high. [&lt;8, 16, 2&gt; 18/17]'>
        /Users/koic/src/github.com/rubocop/rubocop/lib/rubocop/formatter/junit_formatter.rb:29:7
      </failure>
    </testcase>
  </testsuite>
</testsuites>
```

These mean the values of `1 file inspected` and `2 offenses detected` below.

```console
% rubocop lib/rubocop/formatter/junit_formatter.rb
Inspecting 1 file
(snip)

1 file inspected, 2 offenses detected, 2 offenses auto-correctable
```
@bbatsov bbatsov merged commit 5ff1050 into rubocop:master May 7, 2021
@bbatsov
Copy link
Collaborator

bbatsov commented May 7, 2021

Thanks!

@koic koic deleted the support_summary_report_for_junit_formatter branch May 7, 2021 07:35
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.

Better Junit formatter output
2 participants