-
Notifications
You must be signed in to change notification settings - Fork 18
QuickStart Guide
Install into your test project
dotnet add package AltCover
and run
dotnet test /p:AltCover=true
The OpenCover format output will be in file coverage.xml
in the project directory
I'm now getting AltCover.targets(##,#): error : Failed to resolve assembly
or AltCover.targets(##,#): warning : Resolved assembly reference
The instrumentation process needs to find one of the dependencies to do its work. In the latter case, the assembly was found in the default user-level NuGet cache location; in the former, either the AltCover build is too old, the assembly isn't in the default NuGet cache location, or the wrong version was found.
Running
dotnet test /p:AltCover="true" /p:CopyLocalLockFileAssemblies="true"
may resolve the issue.
If this doesn't work, or doing the equivalent of a dotnet publish
into the binaries folder interferes with your downstream process, update to the latest (or at least >= v4.0.653 for the latest enhancements) AltCover build and use the /p:AltCoverDependencyList=
parameter instead to point to the assembly or assemblies in question.
Choose one or both of LCov or Cobertura like this
dotnet test /p:AltCover=true /p:AltCoverCobertura=<path to file> /p:AltCoverLcovReport=<path to file>
or
dotnet test /p:AltCover=true /p:AltCoverOpenCover=false
for NCover format
I'm not interested in how well I cover my test code/I get coverage data from a third-party test runner, which is not of interest
Use the /p:AltCoverAssemblyExcludeFilter
MSBuild property to exclude the test-related assemblies (unit tests, test runners) from coverage, while still fixing up linkage and supporting test call tracking.
MSBuild MySolution.sln
cd <Unit Test project $(OutputDir)>
<path to>/AltCover.exe
cd ./__Instrumented
and run unit tests against the files there.
Under some versions of Mono on non-Windows platforms, with old-school projects, the default values of --debug:full
or --debug:pdbonly
generate no symbols from F# projects -- and without symbols, such assemblies cannot be instrumented. Unlike with C# projects, where the substitution appears to be automatic, to use the necessary --debug:portable
option involves explicitly hand editing the old-school .fsproj
file to have <DebugType>portable</DebugType>
.
You probably need to read the full usage guide.