Skip to content

Latest commit

 

History

History
118 lines (77 loc) · 3.98 KB

README.md

File metadata and controls

118 lines (77 loc) · 3.98 KB

#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 !