Skip to content

Migrate test coverage from coverlet.msbuild to coverlet.collector #7

Description

@CTristan

Background

The org-wide testing standard (open-lobotomy/.github/docs/TESTING.md) moved off coverlet.msbuild build-time instrumentation and onto the coverlet.collector VSTest XPlat Code Coverage data collector (v1.2.0 of the standard, 2026-05-07). The new approach removes the --no-build footgun, plays cleaner with parallel test runs, and aligns with Microsoft's documented modern path.

What needs to change in this repo

  1. Directory.Build.props — drop the <PackageReference Include="coverlet.msbuild"> block from the IsTestProject ItemGroup. Keep coverlet.collector.

  2. Directory.Packages.props — once this repo's OpenLobotomy.Standards pin is bumped to a version that no longer adds coverlet.msbuild as a GlobalPackageReference, remove the coverlet.msbuild PackageVersion line. Until then keep it pinned (the transitive add still needs a managed version).

  3. coverlet.runsettings — add at the repo root, selecting OpenCover format so the threshold checker can parse module totals:

    <?xml version="1.0" encoding="utf-8"?>
    <RunSettings>
      <DataCollectionRunSettings>
        <DataCollectors>
          <DataCollector friendlyName="XPlat code coverage">
            <Configuration>
              <Format>opencover</Format>
            </Configuration>
          </DataCollector>
        </DataCollectors>
      </DataCollectionRunSettings>
    </RunSettings>
  4. CI yaml — if the repo invokes dotnet test directly with /p:CollectCoverage=true, switch to --collect:"XPlat Code Coverage" --settings coverlet.runsettings. If it uses dotnet ci --check (via the org's reusable workflow or directly), no change is needed — the tool picks up the new path once the repo bumps to the new OpenLobotomy.Tooling version.

When to land

After OpenLobotomy.Tooling republishes with the collector path (see open-lobotomy/open-lobotomy-tooling). Until then the changes are inert because the toolchain still routes through msbuild flags.

Acceptance

  • Test gate runs with --collect:"XPlat Code Coverage" (no /p:CollectCoverage)
  • Coverage report lands at **/TestResults/<guid>/coverage.opencover.xml
  • Threshold gate still enforces ≥ 80/80/80

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions