Git Product home page Git Product logo

sharpcover's Introduction

#SharpCover Build Status

C# code coverage tool with Linux (Mono) and Windows (.NET 4.0) support.

##Features

  • CIL instruction coverage
  • Namespace, class, method, line and instruction inclusions/exclusions
  • Inclusions/Exclusions specifications are outside of code.
  • Cross platform Linux/Windows by way of Cecil
  • Easy integration into builds (target user program is invoked seperately)

##Usage

  • After building run SharpCover.exe instrument json where json is a string or file with contents that reflects the following format, most options are optional:
{
    "assemblies": ["../anAssembly.dll", "/someplace/anotherAssembly.dll"],
    "typeInclude": ".*SomePartOfAQualifiedTypeName.*",
    "typeExclude": ".*obviouslyARegex.*",
    "methodInclude": ".*SomePartOfAQualifiedMethodName.*",
    "methodExclude": ".*obviouslyARegex.*",
    "methodBodyExcludes": [
        {
            "method": "System.Void Type::Method()",
            "offsets": [4, 8],
            "lines": ["line content", "++i;"]
        }
    ]
}

The exit code will be zero on instrument success.

  • Excercise the assemblies you listed in the config.

  • Afterwards run SharpCover.exe check in the same directory you ran instrument. The results will be in coverageResults.txt, with missed instructions prefixed with MISS !. The exit code will be zero for success, and total coverage percentage is printed.

###Notes Full method names for methodBodyExcludes can be found in the output, as well as offsets.

The methodBodyExcludes by lines are line content matches ignoring leading/trailing whitespace. This keeps coverage exclusions outside the code while not relying on offsets which can easily change if new code is added to the method. For excluding instructions by line that have no source, the last instruction to have a sequence point is used as that instructions "line".

Remember to rebuild your assemblies before you instrument again !

It is highly recommended to use the includes/excludes to achieve a zero exit from check, otherwise you are cheating yourself !

##Tool Build

Make sure you are in the repository root.

###Linux

Make sure Mono which comes with xbuild is installed.

xbuild Gaillard.SharpCover/Program.csproj

###Windows

Make sure .NET SDK which comes with MSBuild is installed.

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe Gaillard.SharpCover\Program.csproj

Navigate to the Gaillard.SharpCover/bin/Debug directory where the SharpCover.exe executable can be used.

##Contact

Developers may be contacted at:

Questions / Feedback / Feature requests are welcome !!

##Project Build

Make sure you are in the repository root. Make sure nunit-console is installed.

###Linux

Make sure Mono which comes with xbuild is installed.

sh build.sh

###Windows

Make sure .NET SDK which comes with MSBuild is installed.

build.bat

#####Notes

Some paths might need changing depending on your environment.

##Enhancements

A standard output format that can be used with available visualizers would be very useful.

A more complete test suite.

Contributions welcome !

sharpcover's People

Contributors

jcline avatar

Watchers

 avatar  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.