Home

Awesome

MiniCover

Code Coverage Tool for .NET Core

Build Status Nuget Coverage Status

Supported .NET Core SDKs

Installation

MiniCover can be installed as a global tool:

dotnet tool install --global minicover

Or local tool:

dotnet tool install minicover

Commands

This is a simplified documentation of MiniCover commands and options.

Use --help for more information:

minicover --help

When installed as local tool, MiniCover commands must be prefixed with dotnet. Example:

dotnet minicover --help

Instrument

minicover instrument

Use this command to instrument assemblies to record code coverage.

It is based on the following main options:

optiondescriptiontypedefault
sourcessource files to track coverageglobsrc/**/*.cs
exclude-sourcesexceptions to source optionglob**/bin/**/*.cs and **/obj/**/*.cs
teststest files used to recognize test methodsglobtests/**/*.cs and test/**/*.cs
exclude-testsexceptions to tests optionglob**/bin/**/*.cs and **/obj/**/*.cs
assembliesassemblies considered for instrumentationglob**/*.dll
exclude-assembliesExceptions to assemblies optionglob**/obj/**/*.dll

Note 1: Assemblies not related to sources or tests are automatically ignored.

Note 2: Supported syntax for glob values.

Note 3: You can repeat glob options to represent multiple values. Example: --sources "a/**/*.cs" --sources "b/**/*.cs"

This command also generates a coverage.json file with information about the instrumented code.

Uninstrument

minicover uninstrument

Use this command to revert the instrumentation based on coverage.json file.

Make sure you call uninstrument before publishing or packing your application.

Reset

minicover reset

Use this command to reset the recorded coverage so far.

Report

minicover report

Use this command to print a coverage report in the console.

The command exits with failure if the coverage doesn't meet a specific threshold (90% by default).

More commands

Use --help for more information.

Build script example

dotnet restore
dotnet build

# Instrument
minicover instrument

# Reset hits
minicover reset

dotnet test --no-build

# Uninstrument
minicover uninstrument

# Create html reports inside folder coverage-html
minicover htmlreport --threshold 90

# Console report
minicover report --threshold 90

Ignore coverage files

Add the following to your .gitignore file to ignore code coverage results:

coverage-html
coverage-hits
coverage.json

Libraries

When using MiniCover libraries:

By doing that, you reduce the risk of being impacted by future MiniCover changes.

MiniCover.Core

Main MiniCover operations.

Dependency injection configuration:

services.AddMiniCoverCore();

Main interfaces:

MiniCover.Reports

MiniCover reports.

Dependency injection configuration:

services.AddMiniCoverCore();
services.AddMiniCoverReports();

Main interfaces: