Skip to content

About

Cross-platform code coverage for .NET with explicit TFM support and framework-aligned dependencies.

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

0 watching

Forks

 
 

Latest commit

 

History

1,390 Commits

Folders and files

Repository files navigation

Codebelt.Coverlet.MTP

CI NuGet License: MIT

Cross-platform code coverage for .NET with explicit target framework support.

Codebelt.Coverlet.MTP is a deliberately narrow Codebelt-maintained fork of Coverlet for Microsoft Testing Platform integration. Coverlet remains the upstream project; this repository keeps the Coverlet engine and MTP integration recognizable while focusing package identity, target frameworks, dependency groups, and CI/CD on the Codebelt-maintained MTP package.

Reviewed upstream history is retained through 2e0a852 (2026-10-27). The synchronization record explains the adopted fixes, intentional Codebelt differences, and validation.

Warning

Coverage reports from versions 10.0.1 through 10.1.1 can silently omit library assemblies when generated dependency exclusions match a shared assembly-name prefix. Passing tests and a high coverage percentage do not establish that the expected library modules were measured. See the 10.1.2 coverage advisory for affected configurations, upstream origins, verified consumer results, upgrade checks, and the separate .NET Framework instrumentation fix validated with Cuemon.

Scope

This repository produces one public NuGet package: Codebelt.Coverlet.MTP. It preserves the implementation assembly name and namespace used by the MTP extension (coverlet.MTP.dll, Coverlet.MTP, and Coverlet.MTP.TestingPlatformBuilderHook) so existing Microsoft Testing Platform discovery remains compatible.

Retained production projects:

Project Purpose
src/coverlet.MTP Microsoft Testing Platform extension and package entry point.
src/coverlet.core Coverlet instrumentation engine, reporters, and coverage model.
src/coverlet.template netstandard2.0 tracker template embedded by coverlet.core for instrumentation compatibility.

The package supports:

netstandard2.0
net10.0
net11.0

netstandard2.0 is a package compatibility target. Tests execute on net10.0 and net11.0.

Installation

Add the package to an MTP-enabled test project:

dotnet add package Codebelt.Coverlet.MTP

Example test project:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net10.0</TargetFramework>
    <OutputType>Exe</OutputType>
    <UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="xunit.v3" Version="4.0.2" />
    <PackageReference Include="xunit.v3.runner.console" Version="4.0.2" />
    <PackageReference Include="xunit.runner.visualstudio" Version="4.0.1" />
    <PackageReference Include="Codebelt.Coverlet.MTP" Version="10.1.2" />
  </ItemGroup>
</Project>

In xUnit v3 4.x, xunit.v3 includes MTP v2, so this example does not need a direct Microsoft.Testing.Platform reference. The console and Visual Studio runner references are optional for MTP coverage.

With .NET SDK 10 or later, select MTP in the repository's global.json, keeping any existing SDK settings:

{
  "test": {
    "runner": "Microsoft.Testing.Platform"
  }
}

Usage

Run the MTP test project with the normal Coverlet MTP argument:

dotnet test --coverlet

or execute the built test assembly directly:

dotnet exec <test-assembly.dll> --coverlet

Coverage reports are written to the test results/output location. By default the MTP integration emits json and cobertura reports.

Common options:

Option Description
--coverlet Enables coverage collection.
--coverlet-output-format <format> Adds report formats such as json, cobertura, lcov, opencover, or teamcity.
--coverlet-include <filter> Includes assemblies/types matching a Coverlet filter.
--coverlet-exclude <filter> Excludes assemblies/types matching a Coverlet filter.
--coverlet-exclude-by-file <pattern> Excludes source files matching a glob pattern.
--coverlet-exclude-by-attribute <attribute> Excludes code marked with the specified attribute.
--coverlet-include-test-assembly Attempts to include the test assembly where the MTP execution model allows it.

See Coverlet.MTP.Integration.md for the full MTP option reference and configuration-file behavior.

The DocFX documentation provides public API guidance, namespace overviews and compiling integration examples. Build it locally with docfx .docfx/docfx.json; the site is generated in .docfx/wwwroot.

The Codebelt container workflow is available through pwsh .docfx/BuildDocfxImage.ps1 and pwsh .docfx/PublishDocfxImage.ps1. The first builds a local multi-platform documentation image; the second explicitly pushes that image to the Codebelt registry. See the documentation build instructions for prerequisites.

Upstream relationship

This fork is based on coverlet-coverage/coverlet. The intent is not to replace Coverlet or rewrite its instrumentation internals; the fork exists to provide explicit target-framework support and NuGet dependency groups for the Microsoft Testing Platform package.

See UPSTREAM.md for the dated synchronization history, source commits, validation results, omitted changes, and intentional differences from upstream. Release outcomes are summarized in CHANGELOG.md.

For Coverlet drivers outside this repository's scope, such as the console tool, VSTest collector, or MSBuild integration, use the upstream Coverlet packages and documentation.

License and notices

Coverlet is licensed under the MIT license. This fork preserves the upstream MIT license and third-party notices.

About

Cross-platform code coverage for .NET with explicit TFM support and framework-aligned dependencies.

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages