Code Monkey home page Code Monkey logo

minicover's Introduction

MiniCover

Minimalist Code Coverage Tool for .NET Core

Build Status

Heavily based on: https://github.com/gaillard/SharpCover

THIS PROJECT IS WIP, THERE ARE ONLY PRE-RELEASE NUGET PACKAGES

Introduction

Currently no Code Coverage Tool supports .NET Core on Linux.

MiniCover is here to fill that gap. It is focused on simple code base, usage and installation.

Installation

MiniCover was created to be installed as a .NET Cli Tool. You can do that by adding this to a csproj file:

  <ItemGroup>
    <DotNetCliToolReference Include="MiniCover" Version="2.0.0-ci-*" />
  </ItemGroup>

While .NET Core SDK doesn't support CLI Tools at solution level, I recommend the following approach:

Create an empty .NET Core project called tools on your solution. If you follow the .NET community convention, you should have a folder structure similar to:

MyRepository
  src
    ...
  test
    ...
  tools
     tools.csproj
  MySolution.sln

The tools.csproj will be similar to:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <DotNetCliToolReference Include="MiniCover" Version="2.0.0-ci-*" />
  </ItemGroup>
</Project>

Inside the tools folder, execute:

dotnet restore
dotnet minicover --help

After the last command you should see minicover help instructions on your console.

Build script example with MiniCover

dotnet restore
dotnet build

cd tools

# Instrument assemblies inside 'test' folder to detect hits for source files inside 'src' folder
dotnet minicover instrument --workdir ../ --assemblies test/**/bin/**/*.dll --sources src/**/*.cs 

# Reset hits count in case minicover was run for this project
dotnet minicover reset

cd ..

for project in test/**/*.csproj; do dotnet test --no-build $project; done

cd tools

# Uninstrument assemblies, it's important if you're going to publish or deploy build outputs
dotnet minicover uninstrument --workdir ../

# Create html reports inside folder coverage-html
dotnet minicover htmlreport --workdir ../ --threshold 90

# Print console report
# This command returns failure if the coverage is lower than the threshold
dotnet minicover report --workdir ../ --threshold 90

cd ..

Ignore Coverage Files

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

coverage-html
coverage.json
coverage-hits.txt

minicover's People

Contributors

lucaslorentz avatar exyi avatar llatinov avatar rjha1-godaddy avatar jonjomckay avatar higorcesar avatar

Watchers

James Cloos avatar Umut Özel 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.