Skip to content

Commit

Permalink
Improve clarity of line and branch coverage format.
Browse files Browse the repository at this point in the history
- Put percentage first and then covered and total counts in brackets afterwards. Percentage is most critical at a quick glance.

- Put line and brnach coverage on separate lines.

Now it shows in a clean format, including covered branches, total branches and percent of covered branches. Something like this:

```
Coverage report generated for (1/10), (10/10), (2/10), (3/10), (4/10), (5/10), (6/10), (7/10), (8/10), (9/10) to /Users/me/Development/cntral/coverage.
Line Coverage: 58.44% (7554 / 12927)
Branch Coverage: 50.43% (1868 / 3704)
```

When branch coverage is not enabled it simply omits that line, so it appears like this:

```
Coverage report generated for (1/10), (10/10), (2/10), (3/10), (4/10), (5/10), (6/10), (7/10), (8/10), (9/10) to /Users/me/Development/cntral/coverage.
Line Coverage: 58.44% (7554 / 12927)
```
  • Loading branch information
joshuapinter committed Oct 30, 2023
1 parent 79ddf61 commit 8b79c2f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/simplecov-html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ def format(result)
end

def output_message(result)
str = "Coverage report generated for #{result.command_name} to #{output_path}. #{result.covered_lines} / #{result.total_lines} LOC (#{result.covered_percent.round(2)}%) covered."
str += " #{result.covered_branches} / #{result.total_branches} branches (#{result.coverage_statistics[:branch].percent.round(2)}%) covered." if branchable_result?
str
output = "Coverage report generated for #{result.command_name} to #{output_path}."
output += "\nLine Coverage: #{result.covered_percent.round(2)}% (#{result.covered_lines} / #{result.total_lines})"
output += "\nBranch Coverage: #{result.coverage_statistics[:branch].percent.round(2)}% (#{result.covered_branches} / #{result.total_branches})" if branchable_result?
output
end

def branchable_result?
Expand Down

0 comments on commit 8b79c2f

Please sign in to comment.