Skip to content

Instantly share code, notes, and snippets.

@agc93
Created November 17, 2016 04:14
Show Gist options
  • Save agc93/e4dc15d6520659266b20113158dfa4e6 to your computer and use it in GitHub Desktop.
Save agc93/e4dc15d6520659266b20113158dfa4e6 to your computer and use it in GitHub Desktop.
#tool "OpenCover"
Task("Run-Unit-Tests")
.IsDependentOn("Build")
.Does(() =>
{
CreateDirectory(testResultsPath);
CreateDirectory(testResultsPath + "/coverage");
Action<ICakeContext> testAction = ctx => ctx.DotNetCoreTest("./src/Project.Tests", new DotNetCoreTestSettings {
NoBuild = true,
Configuration = configuration,
ArgumentCustomization = args => args.AppendSwitchQuoted("-xml", testResultsPath + "/test-results.xml")
});
OpenCover(testAction,
testResultsPath + "/coverage.xml",
new OpenCoverSettings {
ArgumentCustomization = args => args.Append("-mergeoutput")
}
.WithFilter("+[Project]*")
.ExcludeByAttribute("*.ExcludeFromCodeCoverage*")
.ExcludeByFile("*/*Designer.cs;*/*.g.cs;*/*.g.i.cs"));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment