TopCover 0.1.0

dotnet tool install --global TopCover --version 0.1.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 TopCover --version 0.1.0
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=TopCover&version=0.1.0
nuke :add-package TopCover --version 0.1.0

TopCover

nuget badge

Chasing 100% code coverage is bad, but having no test coverage is also bad!

If a part of your test suite is weak in a way that coverage can detect, it's likely also weak in a way coverage can't detect.

-- Brian Marick

TopCover is a command-line tool, designed to run in a CI process, that helps you analyse test coverage and understand your code's weak points.

TopCover does not run code coverage tools. Instead, you pass it code coverage reports from your tool of choice.

Installation

Install with dotnet tool:

dotnet tool install --global TopCover

Features

# Diff Code Coverage Reports

By providing two coverage reports (e.g. from a PR and the target branch it will be merged in to), TopCover can analyse the difference.

topcover diff -?

--before and --after (required)

The relative path to the Cobertura XML test reports to compare.

For example, you might collect test coverage from a Pull Request ('after') and the main branch ('before'), to understand how the pull request changes the amount of test coverage.

topcover diff --before old.xml --after new.xml

or use the aliases -a and -b

topcover diff -b old.xml -a new.xml

produces:

 |===============================================================|
 |                   |   Before   |    After   |    Change +/-   |
 |===============================================================|
+|  Line Coverage    |   1.0%     |    2.0%    |    + 1.0%       |
-|  Branch Coverage  |   9.9%     |    9.5%    |    - 0.4%       |
 |===============================================================|

--setDevopsVars

Stores the results of the diff in Azure Devops variables, to be accessed in later build steps.

topcover diff -b old.xml -a new.xml --setDevopsVars

sets the following variables:

TOPCOVER_OVERALL_LINE_BEFORE = 88.8
TOPCOVER_OVERALL_LINE_AFTER = 55.5
TOPCOVER_OVERALL_LINE_CHANGE = -33.3
TOPCOVER_OVERALL_LINE_CHANGE_INDICATOR = ↓
TOPCOVER_OVERALL_BRANCH_BEFORE = 50.0
TOPCOVER_OVERALL_BRANCH_AFTER = 50.0
TOPCOVER_OVERALL_BRANCH_CHANGE = 0.0
TOPCOVER_OVERALL_BRANCH_CHANGE_INDICATOR = 

This also stores the full coverage report in a variable; TOPCOVER_PR_COMMENT.

This comment is wrapped in a markdown ```diff code tag, so that it is displayed nicely in a PR comment, e.g. in GitHub:

- task: GitHubComment@0
  inputs:
    gitHubConnection: "MyGitHubConnection"
    repositoryName: "$(Build.Repository.Name)"
    comment: "$(TOPCOVER_PR_COMMENT)"
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last updated
0.1.0 289 8/16/2023
0.0.10 217 8/16/2023
0.0.9 268 8/16/2023
0.0.8 271 8/16/2023
0.0.7 289 8/16/2023
0.0.6 314 8/15/2023
0.0.5 270 8/13/2023
0.0.4 311 8/11/2023
0.0.3 266 8/11/2023
0.0.2 278 8/11/2023