DotCov.Tool 1.4.0

There is a newer version of this package available.
See the version list below for details.
dotnet tool install --global DotCov.Tool --version 1.4.0
                    
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
                    
if you are setting up this repo
dotnet tool install --local DotCov.Tool --version 1.4.0
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=DotCov.Tool&version=1.4.0
                    
nuke :add-package DotCov.Tool --version 1.4.0
                    

Build Coverage

DotCov.Tool

dotcov turns Cobertura XML into a build decision — a table, a markdown block, a JSON payload, and an exit code your CI can act on. No coverage service, no account, no upload unless you ask for one.

Getting started

dotnet tool install -g DotCov.Tool
dotnet test --results-directory TestResults --coverlet --coverlet-output-format cobertura
dotcov check TestResults/ --min-line 80 --min-branch 60 --exclude-generated
PASS: line 96.5% (min 80%), branch 93.0% (min 60%) - thresholds met

Pass the directory, not a file: dotcov globs **/*cobertura*.xml beneath it (hidden directories included) and merges every match, so a sharded test matrix needs no merge step. When it merges more than one report it lists them on stderr; give each test run a fresh results directory, or an earlier run's report is merged too. Timestamped coverlet.MTP files match the default. For generic names such as gcovr's coverage.xml, select the filename explicitly with --pattern.

Commands

dotcov report   TestResults/ --format table|json|md              # parse and render
dotcov check    TestResults/ --min-line 80 --exclude-generated   # CI gate, exit 1 if below
dotcov crap     TestResults/ --max-crap 6                        # per-method risk gate
dotcov diff     before.xml after.xml --format md                 # compare two reports
dotcov snapshot TestResults/ --commit SHA --branch main --project MyApp
dotcov test     tests/MyApp.Tests --min-line 80 -- -c Release    # dotnet test, then report and gate

--github-summary writes the markdown table to $GITHUB_STEP_SUMMARY on pass and fail, so a green build still shows its number.

Testing and gating in one step

dotcov test runs dotnet test with Microsoft Code Coverage writing Cobertura into a fresh TestResults/<run> directory, then prints the table and gates that run like check:

dotcov test tests/MyApp.Tests --min-line 80 --exclude-generated -- -c Release

It passes the coverage options of the runner dotnet test uses in the current directory: DOTNET_TEST_RUNNER, else test.runner in the nearest global.json, else VSTest. On Microsoft.Testing.Platform the test project needs Microsoft.Testing.Extensions.CodeCoverage (TUnit includes it); on VSTest, Microsoft.NET.Test.Sdk brings the Code Coverage collector. Arguments after -- go to dotnet test unchanged. Its output goes to stdout, so stderr still starts with the verdict. A failed test run exits 1 with error: and no coverage verdict.

Exit codes

The gate commands check, crap, and test return 0 only for a measured pass. Their outcomes and shared CLI errors are listed below. Branch on the first stderr token, not the message text:

Token Meaning Exit
PASS: met the threshold 0
FAIL: below the threshold 1
NODATA: the gate lacks the data needed to evaluate 1
DISABLED: both check thresholds are 0, or crap --max-crap is infinite, so the gate cannot fail 1
error: missing path, bad path, parse failure, size cap, bad flag value, unknown flag, extra path, upload failure, failed test run 1
— unknown command 2

report, diff, and snapshot return 0 when rendering and any requested upload succeed. They do not require measured coverage or enforce thresholds. report --threshold affects presentation, not the exit code. Use check when CI must require measured coverage.

An existing directory with no matching reports is valid empty input for reporting commands; a missing path or malformed report is an error. An empty report displays no data in Markdown and - for percentages in the table. Its JSON has files: [], zero totals, and no lineRate or branchRate fields. These represent missing measurements, not 0% coverage. For that same empty directory, check --min-line 1 returns NODATA: and exits 1.

Deciding what to test next

crap scores every method comp² · (1 − cov)³ + comp and sorts worst-first:

$ dotcov crap TestResults/ --exclude-generated --top 5 --max-crap 6
Method                                              Comp     Cov %      CRAP
----------------------------------------------------------------------------
DotCov.Formatters.MarkdownFormatter.Render            43    100.0%      43.0
DotCov.Tool.DotCovCli.RunAsync                        40    100.0%      40.0
DotCov.Tool.DotCovCli.Diff                            14     50.0%      38.5
DotCov.CoberturaParser.ConsumeClass                   34    100.0%      34.0
DotCov.FileCoverage.MergeWith                         32    100.0%      32.0
----------------------------------------------------------------------------
... 250 more methods below (--top 5)
FAIL: worst CRAP 43.0 (max 6) - 69 of 255 methods above threshold

Fully covered code scores its own complexity, fully uncovered code scores comp² + comp — so a 100%-covered 43-branch method still scores 43 and the formula is telling you to split it, not to test it. The default --max-crap is 30, the original CRAP threshold; the 6 above also caps complexity, failing any method above complexity 6 however well it is tested. Complexity comes from coverlet's per-method attribute automatically; for emitters that write none, pass --metrics from dotnet msbuild /t:Metrics (Microsoft.CodeAnalysis.Metrics).

Flags

Flag Effect
--exclude-generated Skip .g.cs, .designer.cs, /obj/, /bin/, /Migrations/, GlobalUsings.cs, Program.cs
--keep <subs> Comma-separated substrings exempt from --exclude-generated; requires it
--pattern <glob> Filename to scan for. Default **/*cobertura*.xml, including timestamped MTP reports
--max-chars <n> Per-file XML character cap. Default 50000000; 0 = uncapped
--format table, json, md
--github-summary Append markdown to $GITHUB_STEP_SUMMARY
--upload <url> POST the JSON payload

Each command accepts only the flags it uses, and dotcov --help lists which. A misspelled flag, --name=value, or a second path is an error, never a silently applied default.

dotcov --help prints the full reference with examples. Percentages are invariant-formatted everywhere: 62.0% on every host, never 62,0%.

Also in this family

DotCov — the parser as a library, zero dependencies · DotCov.Fallout — Fallout build component

Feedback

Documentation · Issues · MIT

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last Updated
4.7.1 42 10/19/2026
4.7.0 48 10/15/2026
4.6.0 41 10/15/2026
4.5.0 42 10/15/2026
4.4.0 48 10/15/2026
4.3.2 38 10/15/2026
4.3.1 52 10/15/2026
4.3.0 68 10/14/2026
4.2.0 62 10/14/2026
4.1.0 71 10/14/2026
4.0.0 70 10/14/2026
3.0.1 68 10/14/2026
3.0.0 81 10/13/2026
2.0.0 75 10/13/2026
1.7.1 91 10/11/2026
1.7.0 140 10/11/2026
1.6.1 78 10/11/2026
1.6.0 85 10/11/2026
1.5.0 80 10/11/2026
1.4.0 89 10/11/2026
Loading failed