Skip to content

Commit

Permalink
display method coverage in console sumary output
Browse files Browse the repository at this point in the history
  • Loading branch information
tonerdo committed May 5, 2018
1 parent 2597da9 commit d2effb3
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/coverlet.msbuild.tasks/CoverageResultTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public override bool Execute()
Directory.CreateDirectory(directory);

var formats = _format.Split(',');
foreach(var format in formats)
foreach (var format in formats)
{
var reporter = new ReporterFactory(format).CreateReporter();
if (reporter == null)
Expand All @@ -64,18 +64,19 @@ public override bool Execute()

double total = 0;
CoverageSummary summary = new CoverageSummary();
ConsoleTable table = new ConsoleTable("Module", "Line Coverage", "Branch Coverage");
ConsoleTable table = new ConsoleTable("Module", "Line", "Branch", "Method");

foreach (var module in result.Modules)
{
double percent = summary.CalculateLineCoverage(module.Value).Percent * 100;
double linePercent = summary.CalculateLineCoverage(module.Value).Percent * 100;
double branchPercent = summary.CalculateBranchCoverage(module.Value).Percent * 100;
table.AddRow(System.IO.Path.GetFileNameWithoutExtension(module.Key), $"{percent}%", $"{branchPercent}%");
total += percent;
double methodPercent = summary.CalculateMethodCoverage(module.Value).Percent * 100;
table.AddRow(Path.GetFileNameWithoutExtension(module.Key), $"{linePercent}%", $"{branchPercent}%", $"{methodPercent}%");
total += linePercent;
}

Console.WriteLine();
Console.WriteLine(table.ToMarkDownString());
Console.WriteLine(table.ToStringAlternative());

double average = total / result.Modules.Count;
if (average < _threshold)
Expand Down

0 comments on commit d2effb3

Please sign in to comment.