A cross-platform pre-instrumenting code coverage tool set for .net/.net core and Mono
$ dotnet add package altcover.cakeContains options to run AltCover as part of dotnet test within a Cake build script.
Given specifications prepare, process and collect (part of the API), extend a dotnet test invocation with coverage collection
{
// do any required customizations here
var altcoverSettings = new AltCover.Cake.CoverageSettings {
PreparationPhase = prepare,
CollectionPhase = collect,
Options = process
};
var testSettings = new DotNetCoreTestSettings {
Configuration = configuration,
NoBuild = true,
};
DotNetCoreTest(<project to test>, // or DotNetTest at v2 or v3
testSettings, altcoverSettings);
});
See the Wiki page for full details
APIs for integration into Cake build scripts (at netstandard2.0 for v1, and netcoreapp3.1 for v2 and v3 Cake APIs)
As the name suggests, it's an alternative coverage approach. Rather than working by hooking the .net profiling API at run-time, it works by weaving the same sort of extra IL into the assemblies of interest ahead of execution. This means that it should work pretty much everywhere, whatever your platform, so long as the executing process has write access to the results file. You can even mix-and-match between platforms used to instrument and those under test.
In particular, while instrumenting .net core assemblies "just works" with this approach, it also supports Mono, as long as suitable .mdb (or .pdb, in recent versions) symbols are available. One major limitation here is that the .mdb format only stores the start location in the source of any code sequence point, and not the end; consequently any nicely coloured reports that take that information into account may show a bit strangely.
Back in 2010, the new .net version finally removed the deprecated profiling APIs that the free NCover 1.5.x series relied upon. The first version of AltCover was written to both fill a gap in functionality, and to give me an excuse for a ground-up F# project to work on. As such, it saw real production use for about a year and a half, until OpenCover reached a point where it could be used for .net4/x64 work (and I could find time to adapt everything downstream that consumed NCover format input).
Fast forwards to autumn 2017, and I get the chance to dust the project off, with the intention of saying that it worked on Mono, too -- and realise that it's déja vu all over again, because .net core didn't yet have profiler based coverage tools either, and the same approach would work there as well.
| Build | GitHub |
| Test coverage | Coveralls |
tl;dr -- legacy framework/Mono support is not going away any time soon.
As net472 can consume netstandard2.0 libraries (everything but the recorder), and .net core 2+ can consume net20 libraries (the recorder), legacy framework/Mono support continues until such a time as it is no longer possible to retain those API levels.
dotnet test API with FAKE and CAKE integration and the AvaloniaUI visualizer