Skip to content

Commit

Permalink
Attempting to generate code coverage output
Browse files Browse the repository at this point in the history
  • Loading branch information
StanleyGoldman committed Sep 7, 2018
1 parent d166a8c commit e5c66aa
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Octokit.Tests/Octokit.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
<ItemGroup>
<ProjectReference Include="..\Octokit\Octokit.csproj" />
<ProjectReference Include="..\Octokit.Reactive\Octokit.Reactive.csproj" />
<PackageReference Include="coverlet.msbuild" Version="2.2.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="NSubstitute" Version="3.1.0" />
</ItemGroup>

Expand Down
1 change: 1 addition & 0 deletions build/Build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Cake.Coverlet" Version="1.3.1" />
<PackageReference Include="Cake.Frosting" Version="0.1.0-alpha0078" />
</ItemGroup>

Expand Down
1 change: 1 addition & 0 deletions build/Tasks/Package.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

[Dependency(typeof(UnitTests))]
[Dependency(typeof(ConventionTests))]
[Dependency(typeof(CodeCoverage))]
[Dependency(typeof(ValidateLINQPadSamples))]
public sealed class Package : FrostingTask<Context>
{
Expand Down
24 changes: 24 additions & 0 deletions build/Tasks/UnitTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
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 @@ -14,4 +16,26 @@ 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 e5c66aa

Please sign in to comment.