Skip to content

Commit

Permalink
Getting net452 coverage as well
Browse files Browse the repository at this point in the history
  • Loading branch information
StanleyGoldman committed Sep 10, 2018
1 parent 2baf3fe commit 55e36f6
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 24 deletions.
41 changes: 41 additions & 0 deletions build/Tasks/CodeCoverage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System.Linq;
using Cake.Common;
using Cake.Common.Diagnostics;
using Cake.Core.IO;
using Cake.Coverlet;
using Cake.Frosting;

[Dependency(typeof(Build))]
public sealed class CodeCoverage : FrostingTask<Context>
{
public override void Run(Context context)
{
foreach (var project in context.Projects.Where(x => x.UnitTests))
{
context.Information("Executing Code Coverage Project {0}...", project.Name);
var dotNetCoreTestSettings = context.GetTestSettings();
dotNetCoreTestSettings.Framework = "netcoreapp2.0";

context.DotNetCoreTest(project.Path.FullPath, dotNetCoreTestSettings, new CoverletSettings()
{
CollectCoverage = true,
CoverletOutputFormat = CoverletOutputFormat.opencover,
CoverletOutputDirectory = DirectoryPath.FromString(@".\coverage-results\"),
CoverletOutputName = $"{project.Name}-netcoreapp2.0"
});

if (context.IsRunningOnWindows())
{
dotNetCoreTestSettings.Framework = "net452";

context.DotNetCoreTest(project.Path.FullPath, dotNetCoreTestSettings, new CoverletSettings()
{
CollectCoverage = true,
CoverletOutputFormat = CoverletOutputFormat.opencover,
CoverletOutputDirectory = DirectoryPath.FromString(@".\coverage-results\"),
CoverletOutputName = $"{project.Name}-net452.0"
});
}
}
}
}
24 changes: 0 additions & 24 deletions build/Tasks/UnitTests.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System.Linq;
using Cake.Common.Diagnostics;
using Cake.Common.Tools.DotNetCore;
using Cake.Core.IO;
using Cake.Coverlet;
using Cake.Frosting;

[Dependency(typeof(Build))]
Expand All @@ -16,26 +14,4 @@ public override void Run(Context context)
context.DotNetCoreTest(project.Path.FullPath, context.GetTestSettings());
}
}
}

[Dependency(typeof(Build))]
public sealed class CodeCoverage : FrostingTask<Context>
{
public override void Run(Context context)
{
foreach (var project in context.Projects.Where(x => x.UnitTests))
{
context.Information("Executing Code Coverage Project {0}...", project.Name);
var dotNetCoreTestSettings = context.GetTestSettings();
dotNetCoreTestSettings.Framework = "netcoreapp2.0";

context.DotNetCoreTest(project.Path.FullPath, dotNetCoreTestSettings, new CoverletSettings()
{
CollectCoverage = true,
CoverletOutputFormat = CoverletOutputFormat.opencover,
CoverletOutputDirectory = DirectoryPath.FromString(@".\coverage-results\"),
CoverletOutputName = $"{project.Name}"
});
}
}
}

0 comments on commit 55e36f6

Please sign in to comment.