Skip to content

Commit

Permalink
update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
tonerdo committed Apr 15, 2018
1 parent 465e07c commit 77d7c70
Showing 1 changed file with 61 additions and 8 deletions.
69 changes: 61 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# coverlet [![Build Status](https://www.travis-ci.org/tonerdo/coverlet.svg?branch=master)](https://www.travis-ci.org/tonerdo/coverlet) [![Build status](https://ci.appveyor.com/api/projects/status/6rdf00wufospr4r8/branch/master?svg=true)](https://ci.appveyor.com/project/tonerdo/coverlet) [![Coverage Status](https://coveralls.io/repos/github/tonerdo/coverlet/badge.svg?branch=master)](https://coveralls.io/github/tonerdo/coverlet?branch=master) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)

Coverlet is a cross platform code coverage library for .NET Core, with support for line and method coverage.
Coverlet is a cross platform code coverage library for .NET Core, with support for line, branch and method coverage.

## Installation

Expand All @@ -24,7 +24,7 @@ Coverlet integrates with the MSBuild system and that allows it to go through the

### Before Tests Run

* Locate the unit test assembly and selects all the referenced assemblies that have PDBs.
* Locates the unit test assembly and selects all the referenced assemblies that have PDBs.
* Instruments the selected assemblies by inserting code to record sequence point hits to a temporary file.

### After Tests Run
Expand All @@ -37,7 +37,7 @@ _Note: The assembly you'd like to get coverage for must be different from the as

## Usage

Coverlet doesn't require any additional setup other than including the NuGet package. It integrates with the `dotnet test` infrastructure built into the .NET Core CLI and when enabled will automatically generate coverage results after tests are run.
Coverlet doesn't require any additional setup other than including the NuGet package. It integrates with the `dotnet test` infrastructure built into the .NET Core CLI and when enabled, will automatically generate coverage results after tests are run.

### Code Coverage

Expand All @@ -51,29 +51,82 @@ After the above command is run, a `coverage.json` file containing the results wi

### Coverage Output

Coverlet can generate coverage results in multiple formats, which is specified using the `CoverletOutputFormat` property. Possible values include `json` (default), `lcov` and `opencover`. For example, the following command emits coverage results in the opencover format:
Coverlet can generate coverage results in multiple formats, which is specified using the `CoverletOutputFormat` property. For example, the following command emits coverage results in the `opencover` format:

```bash
dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
```

Supported Formats:

* json (default)
* lcov
* opencover
* cobertura

The output folder of the coverage result file can also be specified using the `CoverletOutputDirectory` property.

### Excluding Classes/Methods From Coverage
### Threshold

Coverlet allows you to specify a coverage threshold below which it fails the build. This allows you to enforce a minimum coverage percent on all changes to your project.

```bash
dotnet test /p:CollectCoverage=true /p:Threshold=80
```

The above command will automatically fail the build if the average code coverage of all instrumented modules falls below 80%.

By default, Coverlet instruments every method of every class but sometimes for any number of reasons you might want it to ignore a specific method or class altogether. This is easily achieved by creating and applying the `ExcludeFromCoverage` attribute to the method or the class. Coverlet uses just the type name so the `ExcludeFromCoverage` class can be created under any namespace you wish. Also, in line with standard C# convention, either `ExcludeFromCoverage` or `ExcludeFromCoverageAttribute` will work.
### Excluding From Coverage

You can ignore a method or an entire class from code coverage by creating and applying any of the following attributes:

* ExcludeFromCoverage
* ExcludeFromCoverageAttribute

Coverlet just uses the type name, so the attributes can be created under any namespace of your choosing.

## Roadmap

* Branch coverage
* Filter modules to be instrumented
* Support for more output formats (e.g. JaCoCo, Cobertura)
* Support for more output formats (e.g. JaCoCo)
* Console runner (removes the need for requiring a NuGet package)

## Issues & Contributions

If you find a bug or have a feature request, please report them at this repository's issues section. Contributions are highly welcome, however, except for very small changes, kindly file an issue and let's have a discussion before you open a pull request.

### Building The Project

Clone this repo:

```bash
git clone https://github.com/tonerdo/coverlet
```

Change directory to repo root:

```bash
cd coverlet
```

Execute build script:

```bash
dotnet msbuild build.proj
```

This will result in the following:

* Restore all NuGet packages required for building
* Build and publish all projects. Final binaries are placed into `<repo_root>\build\<Configuration>`
* Build and run tests

These steps must be followed before you attempt to open the solution in an IDE (e.g. Visual Studio, Rider) for all projects to be loaded successfully.

## Code of Conduct

This project enforces a code of conduct in line with the contributor covenant. See [CODE OF CONDUCT](CODE_OF_CONDUCT.md) for details.

## License

This project is licensed under the MIT license. See the [LICENSE](LICENSE) file for more info.

0 comments on commit 77d7c70

Please sign in to comment.