From e2b002524159606ebc838628c8fa591b82f18b8b Mon Sep 17 00:00:00 2001 From: Joshua Pinter Date: Wed, 2 Mar 2022 21:05:11 -0700 Subject: [PATCH] Improve clarity of line and branch coverage format. - 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) ``` --- lib/simplecov-html.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/simplecov-html.rb b/lib/simplecov-html.rb index 2887811..665dca9 100644 --- a/lib/simplecov-html.rb +++ b/lib/simplecov-html.rb @@ -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?