Giter Club home page Giter Club logo

minicover_codecoverage's Introduction

MiniCover

Code Coverage Tool for .NET Core

Build Status Nuget Coverage Status

Supported .NET Core SDKs

  • 2.1 (Global tool)
  • 2.2 (Global tool)
  • 3.0 (Global tool or local tool)
  • 3.1 (Global tool or local tool)
  • 5.0 (Global tool or local tool)
  • 6.0 (Global tool or local tool)

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:

option description type default
sources source files to track coverage glob src/**/*.cs
exclude-sources exceptions to source option glob **/bin/**/*.cs and **/obj/**/*.cs
tests test files used to recognize test methods glob tests/**/*.cs and test/**/*.cs
exclude-tests exceptions to tests option glob **/bin/**/*.cs and **/obj/**/*.cs
assemblies assemblies considered for instrumentation glob **/*.dll
exclude-assemblies Exceptions to assemblies option glob **/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

  • cloverreport: Write an Clover-formatted XML report to file
  • coberturareport: Write a cobertura XML report to file
  • coverallsreport: Prepare and/or submit coveralls reports
  • htmlreport: Write html report to folder
  • opencoverreport: Write an OpenCover-formatted XML report to file
  • xmlreport: Write an NCover-formatted XML report to file

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:

  • use dependency injection to create instances
  • use only the main interfaces listed on each package below

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:

  • IInstrumenter
  • IUninstrumenter
  • IHitsReader
  • IHitsResetter

MiniCover.Reports

MiniCover reports.

Dependency injection configuration:

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

Main interfaces:

  • ICloverReport
  • ICoberturaReport
  • IConsoleReport
  • ICoverallsReport
  • IHtmlReport
  • IHtmlSourceFileReport
  • INCoverReport
  • IOpenCoverReport

minicover_codecoverage's People

Contributors

lucaslorentz avatar bhugot avatar day01 avatar kolesnikov-sergey avatar ido-namely avatar ffmathy avatar exyi avatar illia-m avatar llatinov avatar rjha1-godaddy avatar aseduto avatar jonjomckay avatar higorcesar avatar hugopeters1024 avatar aib avatar havocbcn avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.