coverlet-dev - coverlet.msbuild 2.9.1-preview.20.g77b6c08c64

Coverlet is a cross platform code coverage library for .NET, with support for line, branch and method coverage.

PM> Install-Package coverlet.msbuild -Version 2.9.1-preview.20.g77b6c08c64 -Source https://www.myget.org/F/coverlet-dev/api/v3/index.json

Copy to clipboard

> nuget.exe install coverlet.msbuild -Version 2.9.1-preview.20.g77b6c08c64 -Source https://www.myget.org/F/coverlet-dev/api/v3/index.json

Copy to clipboard

> dotnet add package coverlet.msbuild --version 2.9.1-preview.20.g77b6c08c64 --source https://www.myget.org/F/coverlet-dev/api/v3/index.json

Copy to clipboard
<PackageReference Include="coverlet.msbuild" Version="2.9.1-preview.20.g77b6c08c64" />
Copy to clipboard
source https://www.myget.org/F/coverlet-dev/api/v3/index.json

nuget coverlet.msbuild  ~> 2.9.1-preview.20.g77b6c08c64
Copy to clipboard

> choco install coverlet.msbuild --version 2.9.1-preview.20.g77b6c08c64 --source https://www.myget.org/F/coverlet-dev/api/v2

Copy to clipboard
Import-Module PowerShellGet
Register-PSRepository -Name "coverlet-dev" -SourceLocation "https://www.myget.org/F/coverlet-dev/api/v2"
Install-Module -Name "coverlet.msbuild" -RequiredVersion "2.9.1-preview.20.g77b6c08c64" -Repository "coverlet-dev" -AllowPreRelease
Copy to clipboard

Coverlet

Build Status Code%20Coverage License: MIT

Driver Current version Downloads
coverlet.MTP NuGet NuGet
coverlet.collector NuGet NuGet
coverlet.msbuild NuGet NuGet
coverlet.console NuGet NuGet

Coverlet is a cross platform code coverage framework for .NET, with support for line, branch and method coverage. It works with .NET Framework on Windows and .NET Core on all supported platforms.

[!NOTE] Coverlet only supports modern .NET SDK-style projects.

Coverlet documentation reflect the current repository state of the features, not the released ones. Check the changelog to understand if the documented feature you want to use has been officially released.

Main contents

Quick Start

Coverlet can be used through four different drivers

  • VSTest engine integration
  • MSBuild task integration
  • As a .NET Global tool (supports standalone integration tests)
  • New Microsoft Testing Platform integration (coverlet.MTP)

Coverlet supports only SDK-style projects https://docs.microsoft.com/en-us/visualstudio/msbuild/how-to-use-project-sdk?view=vs-2019

NEW Microsoft Testing Platform Integration (coverlet.MTP)

Installation (coverlet.MTP)

dotnet add package coverlet.MTP

[!NOTE] Add the coverlet.MTP package only to test projects that use the Microsoft Testing Platform. This package is designed for projects using Microsoft.Testing.Platform (MTP) as the test runner, not the traditional VSTest runner.

Usage (coverlet.MTP)

Coverlet integrates with the Microsoft Testing Platform as an extension. To enable coverage collection, run your tests with the --coverlet flag:

dotnet run --project <your-test-project> -- --coverlet

Or when using dotnet test with MTP-enabled projects:

dotnet test --coverlet

After the above command is run, coverage report files will be generated in the test results directory. By default, reports are generated in json and cobertura formats.

Additional Options (coverlet.MTP)

Option Description
--coverlet Enable code coverage data collection
--coverlet-output-format Output format(s) for coverage report (json, lcov, opencover, cobertura)
--coverlet-include Include assemblies matching filters (e.g., [Assembly]Type)
--coverlet-exclude Exclude assemblies matching filters (e.g., [Assembly]Type)
--coverlet-include-test-assembly Include test assembly in coverage

Example with options:

dotnet run --project <your-test-project> -- --coverlet --coverlet-output-format cobertura --coverlet-exclude "[xunit.]"

Requirements (coverlet.MTP)

VSTest Integration (preferred due to known issue)

Installation (coverlet.collector)

dotnet add package coverlet.collector

[!NOTE] You MUST add package only to test projects and if you create xunit test projects (dotnet new xunit) you will find the reference already present in csproj file because Coverlet is the default coverage tool for every .NET Core and >= .NET 8 applications, you've only to update to last version if needed. Add coverlet.collector OR coverlet.msbuild package in a test project.

Usage (coverlet.collector)

Coverlet is integrated into the Visual Studio Test Platform as a data collector. To get coverage simply run the following command:

dotnet test --collect:"XPlat Code Coverage"

After the above command is run, a coverage.cobertura.xml file containing the results will be published to the TestResults directory as an attachment.

See documentation for advanced usage.

Requirements (coverlet.collector)

  • .NET 8.0 SDK is required (version 8.0.112 or higher)
  • Microsoft.NET.Test.Sdk version 17.12.0 or higher
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />

MSBuild Integration (suffers of possible known issue)

Installation (coverlet.msbuild)

dotnet add package coverlet.msbuild

N.B. Typically you MUST add package only to test projects. Do not add coverlet.msbuild and coverlet.collector package in a test project.

Usage (coverlet.msbuild)

Coverlet also integrates with the build system to run code coverage after tests. Enabling code coverage is as simple as setting the CollectCoverage property to true

dotnet test /p:CollectCoverage=true

After the above command is run, a coverage.json file containing the results will be generated in the root directory of the test project. A summary of the results will also be displayed in the terminal.

See documentation for advanced usage.

Requirements (coverlet.msbuild)

  • .NET 8.0 SDK is required (version 8.0.112 or higher)
  • .NET Framework that supports .NET Standard 2.0

.NET Global Tool (guide, suffers from possible known issue)

Installation (coverlet.console)

dotnet tool install --global coverlet.console

Usage (coverlet.console)

The coverlet tool is invoked by specifying the path to the assembly that contains the unit tests. You also need to specify the test runner and the arguments to pass to the test runner using the --target and --targetargs options respectively. The invocation of the test runner with the supplied arguments must not involve a recompilation of the unit test assembly or no coverage result will be generated.

The following example shows how to use the familiar dotnet test toolchain:

coverlet /path/to/test-assembly.dll --target "dotnet" --targetargs "test /path/to/test-project --no-build"

Note: The --no-build flag is specified so that the /path/to/test-assembly.dll assembly isn't rebuilt

See documentation for advanced usage.

Requirements (coverlet.console)

How It Works

Coverlet generates code coverage information by going through the following process:

Before Tests Run

  • Locates the unit test assembly and selects all the referenced assemblies that have PDBs.
  • Instruments the selected assemblies by inserting code to record sequence point hits to a temporary file.

After Tests Run

  • Restore the original non-instrumented assembly files.
  • Read the recorded hits information from the temporary file.
  • Generate the coverage result from the hits information and write it to a file.

Deterministic build support

Coverlet supports coverage for deterministic builds. The solution at the moment is not optimal and need a workaround. Take a look at documentation.

Are you in trouble with some feature? Check on examples

Known Issues

Unfortunately we have some known issues

Cake Add-In

If you're using Cake Build for your build script you can use the Cake.Coverlet add-in to provide you extensions to dotnet test for passing Coverlet arguments in a strongly typed manner.

Visual Studio Add-In

If you want to visualize coverlet output inside Visual Studio while you code, you can use the following addins depending on your platform.

Windows

If you're using Visual Studio on Windows, you can use the Fine Code Coverage extension. Visualization is updated when you run unit tests inside Visual Studio.

Mac OS

If you're using Visual Studio for Mac, you can use the VSMac-CodeCoverage extension.

Consume nightly build

We offer nightly build of master for all packages. See the documentation

Issues & Contributions

If you find a bug or have a feature request, please report them at this repository's issues section. See the CONTRIBUTING GUIDE for details on building and contributing to this project.

Coverlet Team

Author and owner

Co-maintainers

Code of Conduct

This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behavior in our community.

For more information, see the .NET Foundation Code of Conduct.

Credits

Part of the code is based on work done by OpenCover team https://github.com/OpenCover

License

This project is licensed under the MIT license. See the LICENSE file for more info.

Supported by the .NET Foundation

Owners

Toni Solarin-Sodara

Authors

tonerdo

Project URL

https://github.com/coverlet-coverage/coverlet

License

Unknown

Tags

coverage testing unit-test lcov opencover quality

Info

16868 total downloads
362 downloads for version 2.9.1-preview.20.g77b6c08c64
Download (2.48 MB)
Found on the current feed only

Package history

Version Size Last updated Downloads Mirrored?
2.9.1-preview.24.g6479f627e4 2.48 MB Thu, 27 Aug 2020 00:06:02 GMT 555
2.9.1-preview.23.g2cfe8ea110 2.48 MB Tue, 04 Aug 2020 00:04:45 GMT 105
2.9.1-preview.21.g778b697655 2.48 MB Fri, 24 Jul 2020 00:05:04 GMT 94
2.9.1-preview.20.g77b6c08c64 2.48 MB Tue, 21 Jul 2020 00:04:49 GMT 362
2.9.1-preview.19.ge99520eb06 2.48 MB Tue, 14 Jul 2020 00:04:57 GMT 206
2.9.1-preview.18.gfe977b6c59 2.48 MB Mon, 13 Jul 2020 00:06:54 GMT 61
2.9.1-preview.17.g7385f59e17 2.48 MB Sun, 12 Jul 2020 00:05:32 GMT 180
2.9.1-preview.13.g7c12e15963 2.48 MB Thu, 09 Jul 2020 00:04:49 GMT 111
2.9.1-preview.12.g822cb6683c 2.48 MB Sat, 27 Jun 2020 00:04:23 GMT 73
2.9.1-preview.10.gf7c3fd4e3a 2.48 MB Sun, 14 Jun 2020 00:04:09 GMT 157
2.9.1-preview.8.ge848786b0d 2.47 MB Mon, 08 Jun 2020 00:07:17 GMT 79
2.9.1-preview.6.g8468bcf36c 2.47 MB Sun, 07 Jun 2020 00:07:26 GMT 81
2.9.1-preview.5.g4974550fa6 2.47 MB Fri, 05 Jun 2020 00:03:09 GMT 82
2.9.1-preview.3.gade9498891 2.47 MB Thu, 04 Jun 2020 00:05:10 GMT 60
2.9.1-preview.2.g4fcf22dff2 2.47 MB Sun, 31 May 2020 00:02:53 GMT 69
2.9.0-preview-0001-gfa138c0e00 2.47 MB Sun, 12 Apr 2020 00:04:26 GMT 170
2.9.0-preview.23.ge438dbf568 2.47 MB Fri, 29 May 2020 00:04:45 GMT 71
2.9.0-preview.22.gfb1124cd3d 2.47 MB Mon, 25 May 2020 00:03:59 GMT 77
2.9.0-preview.20.g180bee479f 2.47 MB Tue, 19 May 2020 00:04:36 GMT 78
2.9.0-preview.18.g8a1026dd2b 2.47 MB Sat, 16 May 2020 00:05:47 GMT 230
2.9.0-preview.17.g3c55332cce 2.47 MB Mon, 11 May 2020 00:08:43 GMT 67
2.9.0-preview.13.ge1ec1cce8c 2.47 MB Fri, 08 May 2020 00:04:35 GMT 67
2.9.0-preview.10.gb9ebbc6541 2.47 MB Sun, 03 May 2020 00:03:58 GMT 73
2.9.0-preview.9.g882b4c87b7 2.47 MB Sat, 02 May 2020 00:03:57 GMT 67
2.9.0-preview.8.g4e9deb5576 2.47 MB Mon, 20 Apr 2020 00:05:08 GMT 58
2.9.0-preview.7.g2e2b578fcc 2.47 MB Sun, 19 Apr 2020 00:04:29 GMT 72
2.9.0-preview.6.ga0e22ec622 2.47 MB Sat, 18 Apr 2020 00:05:10 GMT 72
2.9.0-preview.4.gf83cd9e0a7 2.47 MB Tue, 14 Apr 2020 00:05:32 GMT 65
2.8.46-g3f81828821 2.47 MB Tue, 31 Mar 2020 00:04:18 GMT 845
2.8.45-g4c1cdf9ee9 2.47 MB Thu, 26 Mar 2020 00:05:10 GMT 835
2.8.44-gcd945985d8 2.47 MB Mon, 23 Mar 2020 00:02:46 GMT 69
2.8.41-g8ddbb6ff3c 2.47 MB Sun, 22 Mar 2020 00:02:37 GMT 84
2.8.40-g0cc2548b27 2.47 MB Wed, 18 Mar 2020 00:02:55 GMT 88
2.8.38-g34d6dc5ff6 2.47 MB Sat, 14 Mar 2020 00:02:40 GMT 77
2.8.37-g39e9b1036a 2.47 MB Wed, 11 Mar 2020 00:03:05 GMT 64
2.8.36-g54e576f75d 2.47 MB Sun, 01 Mar 2020 00:02:30 GMT 71
2.8.35-g830ad8a572 2.47 MB Sat, 29 Feb 2020 00:02:28 GMT 68
2.8.33-g84dcfdb7b4 2.47 MB Mon, 24 Feb 2020 00:02:49 GMT 68
2.8.32-gfd1030f8c2 2.47 MB Sun, 23 Feb 2020 00:02:54 GMT 80
2.8.31-gbcd754a70e 2.47 MB Thu, 20 Feb 2020 00:02:29 GMT 190
2.8.30-g650d4cf4a3 2.47 MB Wed, 19 Feb 2020 00:02:32 GMT 68
2.8.29-gd2f0fd2248 2.47 MB Mon, 17 Feb 2020 00:02:24 GMT 71
2.8.28-g7f292f9fbf 2.47 MB Thu, 06 Feb 2020 00:02:44 GMT 78
2.8.27-gfd68090b0a 2.47 MB Wed, 05 Feb 2020 00:02:24 GMT 756
2.8.26-g8b5096f15e 2.47 MB Thu, 30 Jan 2020 00:06:05 GMT 77
2.8.25-g074a201a91 2.47 MB Wed, 29 Jan 2020 00:02:33 GMT 65
2.8.22-gc314586a64 2.47 MB Tue, 28 Jan 2020 00:02:28 GMT 111
2.8.20-ga2b0373d60 2.47 MB Mon, 27 Jan 2020 08:41:03 GMT 77
2.8.6-g8cb1ebc0da 2.46 MB Sun, 12 Jan 2020 00:02:39 GMT 97
2.8.4-gbd2f1841a5 2.46 MB Thu, 09 Jan 2020 00:05:38 GMT 54
2.8.3-g7080820b21 2.46 MB Mon, 06 Jan 2020 00:02:43 GMT 78
2.8.2-g3ca6223691 2.46 MB Sat, 04 Jan 2020 00:02:35 GMT 67
2.8.1-ge9dcf4c56a 2.47 MB Tue, 07 Apr 2020 00:04:48 GMT 72
2.8.1-g83aa10e32b 2.47 MB Fri, 03 Apr 2020 00:04:34 GMT 56
2.8.1-g7de6209cc6 2.47 MB Sun, 05 Apr 2020 00:04:07 GMT 69
2.8.1-g62ff6d7c2c 2.47 MB Mon, 06 Apr 2020 00:04:15 GMT 62
2.8.1-g51151d69b2 2.47 MB Fri, 10 Apr 2020 00:04:13 GMT 72
2.8.1-g4e177f0c57 2.47 MB Thu, 09 Apr 2020 17:20:16 GMT 76
2.8.1-g0c24f74a27 2.47 MB Sat, 04 Apr 2020 00:03:58 GMT 64
2.7.55-g0f031e29c2 2.46 MB Tue, 24 Dec 2019 00:02:40 GMT 75
2.7.54-g81daeb8959 2.46 MB Sun, 22 Dec 2019 00:02:42 GMT 75
2.7.52-g5f997cea13 2.46 MB Sat, 21 Dec 2019 00:02:44 GMT 63
2.7.50-g7cad9b3f58 2.46 MB Sat, 14 Dec 2019 00:02:34 GMT 80
2.7.49-ge15e653492 2.46 MB Fri, 13 Dec 2019 00:06:44 GMT 75
2.7.48-g45d8d4ee42 2.46 MB Tue, 10 Dec 2019 00:02:50 GMT 80
2.7.47-g6336e5811e 2.46 MB Mon, 09 Dec 2019 00:02:48 GMT 74
2.7.45-gca10ca949d 2.46 MB Sun, 08 Dec 2019 00:02:37 GMT 69
2.7.38-g53562c6460 2.46 MB Sat, 07 Dec 2019 00:02:53 GMT 75
2.7.37-g59ca277294 2.46 MB Thu, 05 Dec 2019 00:02:48 GMT 82
2.7.36-gb1837af930 2.46 MB Wed, 04 Dec 2019 00:02:42 GMT 77
2.7.30-g63dbda8190 2.41 MB Sat, 30 Nov 2019 00:02:40 GMT 73
2.7.29-ga23c3a3d0e 2.41 MB Fri, 29 Nov 2019 00:02:50 GMT 75
2.7.27-ge123f6b54a 2.41 MB Sat, 23 Nov 2019 00:02:40 GMT 82
2.7.26-g4d9f3cac3b 2.41 MB Wed, 13 Nov 2019 00:05:02 GMT 67
2.7.24-g180c8a69f2 2.41 MB Sat, 09 Nov 2019 00:02:47 GMT 101
2.7.21-g6630c0acce 2.41 MB Thu, 07 Nov 2019 00:05:45 GMT 82
2.7.20-g4f3f25fda9 2.47 MB Thu, 31 Oct 2019 00:04:00 GMT 79
2.7.19-g545b8fc912 2.47 MB Wed, 23 Oct 2019 00:03:12 GMT 66
2.7.18-gfd17f4be6e 2.47 MB Wed, 16 Oct 2019 00:03:11 GMT 64
2.7.17-gd245f470a3 2.47 MB Tue, 15 Oct 2019 00:03:06 GMT 62
2.7.16-g2a90a1c9c7 2.47 MB Sun, 13 Oct 2019 00:02:55 GMT 76
2.7.14-g207f346bee 2.46 MB Sat, 12 Oct 2019 00:03:00 GMT 61
2.7.12-gf3cce5ded8 2.46 MB Thu, 10 Oct 2019 00:03:17 GMT 78
2.7.11-g9321bd7ad2 2.46 MB Wed, 09 Oct 2019 00:03:00 GMT 65
2.7.10-g026c74a5bd 2.46 MB Sun, 06 Oct 2019 00:02:52 GMT 79
2.7.9-g0614f871bc 2.46 MB Tue, 01 Oct 2019 00:03:03 GMT 78
2.7.8-g589e210e74 2.46 MB Fri, 27 Sep 2019 00:03:03 GMT 99
2.7.7-g213b927ac7 2.46 MB Tue, 24 Sep 2019 00:03:06 GMT 65
2.7.1-g4ca01eb239 2.46 MB Mon, 23 Sep 2019 00:03:06 GMT 69
2.6.82-gf24b9d567c 2.46 MB Sun, 22 Sep 2019 00:02:43 GMT 73
2.6.80-g82a920864a 2.46 MB Fri, 20 Sep 2019 00:03:00 GMT 65
2.6.79-g2aa8ed683c 2.46 MB Wed, 18 Sep 2019 00:03:01 GMT 80
2.6.78-g903f61b6de 2.46 MB Tue, 17 Sep 2019 00:03:03 GMT 162
2.6.69-gafe227b39e 2.46 MB Sat, 07 Sep 2019 00:02:50 GMT 79
2.6.68-g75520ddc5f 2.46 MB Thu, 05 Sep 2019 00:02:59 GMT 72
2.6.66-g15eeb98f5d 2.46 MB Wed, 28 Aug 2019 19:08:08 GMT 65
2.6.65-g70b3ef31da 2.46 MB Wed, 21 Aug 2019 00:03:03 GMT 78
2.6.64-g428034d46a 2.46 MB Fri, 16 Aug 2019 00:02:54 GMT 64
2.6.63-g4e02ab0a27 2.46 MB Thu, 15 Aug 2019 00:02:54 GMT 77
2.6.61-g872e087e6a 2.46 MB Tue, 13 Aug 2019 00:03:07 GMT 79
2.6.59-gcca16685ed 2.46 MB Sat, 10 Aug 2019 00:02:50 GMT 59
2.6.58-gda509492a0 2.42 MB Fri, 09 Aug 2019 00:03:04 GMT 67
2.6.56-g83e93db6d8 2.42 MB Sun, 04 Aug 2019 00:03:38 GMT 853
2.6.55-g55c866f142 2.42 MB Thu, 01 Aug 2019 00:03:04 GMT 67
2.6.54-g49ec4b9703 2.42 MB Sun, 28 Jul 2019 00:02:51 GMT 81
2.6.53-g4d61d296e3 2.42 MB Sat, 27 Jul 2019 08:19:12 GMT 61
2.6.52-g84d47a144c 2.42 MB Fri, 26 Jul 2019 00:02:44 GMT 69
2.6.51-ged9195d73b 2.42 MB Thu, 25 Jul 2019 00:03:07 GMT 75
2.6.49-ge3d1a6c9df 2.42 MB Wed, 24 Jul 2019 00:02:58 GMT 72
2.6.47-g016c3630ca 2.42 MB Wed, 17 Jul 2019 03:20:48 GMT 79
2.6.46-ga339983da4 2.42 MB Mon, 15 Jul 2019 12:42:38 GMT 70
2.6.45-gec04c7d82f 2.42 MB Thu, 04 Jul 2019 08:31:20 GMT 64
2.6.44-ge159335949 2.42 MB Mon, 01 Jul 2019 00:03:07 GMT 78
2.6.41-g53a3242437 2.42 MB Fri, 28 Jun 2019 00:02:56 GMT 143
2.6.40-gd5d0a0b59c 2.42 MB Sat, 22 Jun 2019 05:16:34 GMT 75
2.6.39-gf14ee2b7fb 2.42 MB Tue, 18 Jun 2019 00:03:01 GMT 98
2.6.37-g2bbe53f6e0 2.59 MB Mon, 17 Jun 2019 01:35:08 GMT 93
2.6.36-gcc60b0dba7 2.59 MB Sun, 16 Jun 2019 00:03:05 GMT 78
2.6.33-g66a0119867 2.59 MB Tue, 11 Jun 2019 00:02:51 GMT 58
2.6.31-g0f85b3ce80 2.59 MB Sat, 08 Jun 2019 00:02:50 GMT 56
2.6.25-g6209239d69 2.42 MB Mon, 03 Jun 2019 00:02:47 GMT 85
2.6.24-ge5998d8fbd 2.42 MB Sat, 01 Jun 2019 00:02:52 GMT 69
2.6.2-g24d5acafc6 2.59 MB Fri, 07 Jun 2019 00:03:18 GMT 66
2.6.1-gbaad0091a5 2.42 MB Mon, 27 May 2019 00:11:03 GMT 72
2.6.1-gb8abd2b9a3 2.42 MB Tue, 28 May 2019 00:03:15 GMT 67
2.6.1-g7806f43ae7 2.42 MB Mon, 27 May 2019 00:27:28 GMT 71
2.6.1-g5a139b200f 2.42 MB Thu, 30 May 2019 00:02:57 GMT 70
2.6.1-g2905b634fc 2.42 MB Mon, 27 May 2019 00:21:59 GMT 79
2.6.1-g2150873b65 2.42 MB Mon, 27 May 2019 00:14:40 GMT 59
2.6.1-g0f6cf3fc85 2.42 MB Sun, 26 May 2019 23:56:40 GMT 73
2.6.1-g0dd56242f2 2.42 MB Wed, 29 May 2019 00:03:09 GMT 76
2.6.1-g02708bbaea 2.42 MB Mon, 27 May 2019 00:02:56 GMT 2594