Skip to content

Commit d96b9b9

Browse files
committed
Add total line coverage for badge generators
1 parent 30c000b commit d96b9b9

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/coverlet.console/Program.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ static int Main(string[] args)
8585
var exceptionBuilder = new StringBuilder();
8686
var coverageTable = new ConsoleTable("Module", "Line", "Branch", "Method");
8787
var thresholdFailed = false;
88+
var overallLineCoverage = summary.CalculateLineCoverage(result.Modules).Percent * 100;
8889

8990
foreach (var _module in result.Modules)
9091
{
@@ -118,6 +119,8 @@ static int Main(string[] args)
118119

119120
logger.LogInformation(string.Empty);
120121
logger.LogInformation(coverageTable.ToStringAlternative());
122+
logger.LogInformation(string.Empty);
123+
logger.LogInformation($"Total {overallLineCoverage}%");
121124

122125
if (thresholdFailed)
123126
throw new Exception(exceptionBuilder.ToString().TrimEnd(Environment.NewLine.ToCharArray()));

src/coverlet.msbuild.tasks/CoverageResultTask.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ public override bool Execute()
7979
var summary = new CoverageSummary();
8080
var exceptionBuilder = new StringBuilder();
8181
var coverageTable = new ConsoleTable("Module", "Line", "Branch", "Method");
82+
var overallLineCoverage = summary.CalculateLineCoverage(result.Modules).Percent * 100;
8283

8384
foreach (var module in result.Modules)
8485
{
@@ -112,6 +113,8 @@ public override bool Execute()
112113

113114
Console.WriteLine();
114115
Console.WriteLine(coverageTable.ToStringAlternative());
116+
Console.WriteLine();
117+
Console.WriteLine($"Total {overallLineCoverage}%");
115118

116119
if (thresholdFailed)
117120
throw new Exception(exceptionBuilder.ToString().TrimEnd(Environment.NewLine.ToCharArray()));

0 commit comments

Comments
 (0)