{"id":27002538,"url":"https://github.com/tonerdo/coverlet","last_synced_at":"2025-04-04T05:01:51.591Z","repository":{"id":37789289,"uuid":"119716732","full_name":"coverlet-coverage/coverlet","owner":"coverlet-coverage","description":"Cross platform code coverage for .NET","archived":false,"fork":false,"pushed_at":"2024-09-10T22:40:32.000Z","size":4480,"stargazers_count":2987,"open_issues_count":88,"forks_count":387,"subscribers_count":45,"default_branch":"master","last_synced_at":"2024-10-29T15:47:30.413Z","etag":null,"topics":["bytecode","code-coverage","coverage","coverage-library","coverlet","cross-platform","dotnet","dotnet-core","instrumentation","unittest"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coverlet-coverage.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-01-31T17:01:26.000Z","updated_at":"2024-10-25T13:04:52.000Z","dependencies_parsed_at":"2024-04-11T20:23:53.865Z","dependency_job_id":"0eeabd48-8ff4-4654-b87d-409ac3929ddb","html_url":"https://github.com/coverlet-coverage/coverlet","commit_stats":{"total_commits":967,"total_committers":114,"mean_commits":8.482456140350877,"dds":0.7073422957600828,"last_synced_commit":"7c8c6fae2715308a0116e2b40221f06cbf07e7bd"},"previous_names":["tonerdo/coverlet"],"tags_count":34,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coverlet-coverage%2Fcoverlet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coverlet-coverage%2Fcoverlet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coverlet-coverage%2Fcoverlet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coverlet-coverage%2Fcoverlet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coverlet-coverage","download_url":"https://codeload.github.com/coverlet-coverage/coverlet/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247123097,"owners_count":20887261,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bytecode","code-coverage","coverage","coverage-library","coverlet","cross-platform","dotnet","dotnet-core","instrumentation","unittest"],"created_at":"2025-04-04T05:01:12.587Z","updated_at":"2025-04-04T05:01:51.572Z","avatar_url":"https://github.com/coverlet-coverage.png","language":"C#","funding_links":[],"categories":["Frameworks, Libraries and Tools","框架, 库和工具","Code Analysis and Metrics"],"sub_categories":["Code Analysis and Metrics","代码分析和指标"],"readme":"# Coverlet\n\n[![Build Status](https://dev.azure.com/tonerdo/coverlet/_apis/build/status/coverlet-coverage.coverlet?branchName=master)](https://dev.azure.com/tonerdo/coverlet/_build/latest?definitionId=5\u0026branchName=master) ![Code%20Coverage](https://img.shields.io/azure-devops/coverage/tonerdo/coverlet/5/master?label=Code%20Coverage) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/coverlet-coverage/coverlet/blob/master/LICENSE)\n\n| Driver  |  Current version  | Downloads  |\n|---|---|---|\n|  coverlet.collector  | [![NuGet](https://img.shields.io/nuget/v/coverlet.collector.svg)](https://www.nuget.org/packages/coverlet.collector/)    |  [![NuGet](https://img.shields.io/nuget/dt/coverlet.collector.svg)](https://www.nuget.org/packages/coverlet.collector/)\n|  coverlet.msbuild |  [![NuGet](https://img.shields.io/nuget/v/coverlet.msbuild.svg)](https://www.nuget.org/packages/coverlet.msbuild/)   |  [![NuGet](https://img.shields.io/nuget/dt/coverlet.msbuild.svg)](https://www.nuget.org/packages/coverlet.msbuild/) |\n|  coverlet.console |  [![NuGet](https://img.shields.io/nuget/v/coverlet.console.svg)](https://www.nuget.org/packages/coverlet.console/)     |  [![NuGet](https://img.shields.io/nuget/dt/coverlet.console.svg)](https://www.nuget.org/packages/coverlet.console/) |\n\nCoverlet is a cross platform code coverage framework for .NET, with support for line, branch and method coverage. It works with [.NET Framework](Documentation/KnownIssues.md#badimageformatexception-net-framework-47x-48x) on Windows and .NET Core on all supported platforms.\n\n**Coverlet documentation reflect the current repository state of the features, not the released ones.**\n**Check the [changelog](Documentation/Changelog.md) to understand if the documented feature you want to use has been officially released.**\n\n## Main contents\n\n* [QuickStart](#quick-start)\n* [How It Works](#how-it-works)\n* [Drivers features differences](Documentation/DriversFeatures.md)\n* [Deterministic build support](#deterministic-build-support)\n* [Known Issues](#known-issues)\n* [Consume nightly build](#consume-nightly-build)\n* [Feature samples](Documentation/Examples.md)\n* [Cake Add-In](#cake-add-in)\n* [Visual Studio Add-In](#visual-studio-add-in)\n* [Changelog](Documentation/Changelog.md)\n* [Roadmap](Documentation/Roadmap.md)\n\n## Quick Start\n\nCoverlet can be used through three different *drivers*\n\n* VSTest engine integration\n* MSBuild task integration\n* As a .NET Global tool (supports standalone integration tests)\n\nCoverlet supports only SDK-style projects https://docs.microsoft.com/en-us/visualstudio/msbuild/how-to-use-project-sdk?view=vs-2019\n\n### VSTest Integration (preferred due to [known issue](https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/KnownIssues.md#1-vstest-stops-process-execution-earlydotnet-test))\n\n### Installation (coverlet.collector)\n\n```bash\ndotnet add package coverlet.collector\n```\n\nN.B. You **MUST** add package only to test projects and if you create xunit test projects (`dotnet new xunit`) you'll find the reference already present in `csproj` file because Coverlet is the default coverage tool for every .NET Core and \u003e= .NET 6 applications, you've only to update to last version if needed. Do not add `coverlet.collector` and `coverlet.msbuild` package in a test project.\n\n### Usage (coverlet.collector)\n\nCoverlet is integrated into the Visual Studio Test Platform as a [data collector](https://github.com/Microsoft/vstest-docs/blob/master/docs/extensions/datacollector.md). To get coverage simply run the following command:\n\n```bash\ndotnet test --collect:\"XPlat Code Coverage\"\n```\n\nAfter the above command is run, a `coverage.cobertura.xml` file containing the results will be published to the `TestResults` directory as an attachment.\n\nSee [documentation](Documentation/VSTestIntegration.md) for advanced usage.\n\n#### Requirements (coverlet.collector)\n\n* _You need to be running .NET 6.0 SDK v6.0.316 or newer_\n* _You need to reference version 17.5.0 and above of Microsoft.NET.Test.Sdk_\n\n```xml\n\u003cPackageReference Include=\"Microsoft.NET.Test.Sdk\" Version=\"17.5.0\" /\u003e\n```\n\n### MSBuild Integration (suffers of possible [known issue](https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/KnownIssues.md#1-vstest-stops-process-execution-earlydotnet-test))\n\n### Installation (coverlet.msbuild)\n\n```bash\ndotnet add package coverlet.msbuild\n```\n\nN.B. Typically you **MUST** add package only to test projects. Do not add `coverlet.msbuild` and `coverlet.collector` package in a test project.\n\n### Usage (coverlet.msbuild)\n\nCoverlet also integrates with the build system to run code coverage after tests. Enabling code coverage is as simple as setting the `CollectCoverage` property to `true`\n\n```bash\ndotnet test /p:CollectCoverage=true\n```\n\nAfter the above command is run, a `coverage.json` file containing the results will be generated in the root directory of the test project. A summary of the results will also be displayed in the terminal.\n\nSee [documentation](Documentation/MSBuildIntegration.md) for advanced usage.\n\n#### Requirements (coverlet.msbuild)\n\nRequires a runtime that support _.NET Standard 2.0 and above_\n\n### .NET Global Tool ([guide](https://docs.microsoft.com/en-us/dotnet/core/tools/global-tools), suffers from possible [known issue](https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/KnownIssues.md#1-vstest-stops-process-execution-earlydotnet-test))\n\n### Installation (coverlet.console)\n\n```bash\ndotnet tool install --global coverlet.console\n```\n\n### Usage (coverlet.console)\n\nThe `coverlet` tool is invoked by specifying the path to the assembly that contains the unit tests. You also need to specify the test runner and the arguments to pass to the test runner using the `--target` and `--targetargs` options respectively. The invocation of the test runner with the supplied arguments **must not** involve a recompilation of the unit test assembly or no coverage result will be generated.\n\nThe following example shows how to use the familiar `dotnet test` toolchain:\n\n```bash\ncoverlet /path/to/test-assembly.dll --target \"dotnet\" --targetargs \"test /path/to/test-project --no-build\"\n```\n\n_Note: The `--no-build` flag is specified so that the `/path/to/test-assembly.dll` assembly isn't rebuilt_\n\nSee [documentation](Documentation/GlobalTool.md) for advanced usage.\n\n#### Requirements (coverlet.console)\n\n.NET global tools rely on a .NET Core runtime installed on your machine https://docs.microsoft.com/en-us/dotnet/core/tools/global-tools#what-could-go-wrong\n\n.NET Coverlet global tool requires _.NET Core 2.2 and above_\n\n## How It Works\n\nCoverlet generates code coverage information by going through the following process:\n\n### Before Tests Run\n\n* Locates the unit test assembly and selects all the referenced assemblies that have PDBs.\n* Instruments the selected assemblies by inserting code to record sequence point hits to a temporary file.\n\n### After Tests Run\n\n* Restore the original non-instrumented assembly files.\n* Read the recorded hits information from the temporary file.\n* Generate the coverage result from the hits information and write it to a file.\n\n## Deterministic build support\n\nCoverlet supports coverage for deterministic builds. The solution at the moment is not optimal and need a workaround.\nTake a look at [documentation](Documentation/DeterministicBuild.md).\n\n## Are you in trouble with some feature? Check on [examples](Documentation/Examples.md)!\n\n## Known Issues\n\nUnfortunately we have some known issues, check it [here](Documentation/KnownIssues.md)\n\n## Cake Add-In\n\nIf you're using [Cake Build](https://cakebuild.net) for your build script you can use the [Cake.Coverlet](https://github.com/Romanx/Cake.Coverlet) add-in to provide you extensions to dotnet test for passing Coverlet arguments in a strongly typed manner.\n\n## Visual Studio Add-In\n\nIf you want to visualize coverlet output inside Visual Studio while you code, you can use the following addins depending on your platform.\n\n### Windows\n\nIf you're using Visual Studio on Windows, you can use the [Fine Code Coverage](https://marketplace.visualstudio.com/items?itemName=FortuneNgwenya.FineCodeCoverage) extension.\nVisualization is updated when you run unit tests inside Visual Studio.\n\n### Mac OS\n\nIf you're using Visual Studio for Mac, you can use the [VSMac-CodeCoverage](https://github.com/ademanuele/VSMac-CodeCoverage) extension.\n\n## Consume nightly build\n\nWe offer nightly build of master for all packages.\nSee the [documentation](Documentation/ConsumeNightlyBuild.md)\n\n## Issues \u0026 Contributions\n\nIf you find a bug or have a feature request, please report them at this repository's issues section. See the [CONTRIBUTING GUIDE](CONTRIBUTING.md) for details on building and contributing to this project.\n\n## Coverlet Team\n\nAuthor and owner\n* [Toni Solarin-Sodara](https://github.com/tonerdo)\n\nCo-maintainers\n\n* [David Müller](https://github.com/daveMueller)\n* [Bert](https://github.com/Bertk)\n* [Peter Liljenberg](https://github.com/petli)\n* [Marco Rossignoli](https://github.com/MarcoRossignoli)\n\n## Code of Conduct\n\nThis project has adopted the code of conduct defined by the Contributor Covenant\nto clarify expected behavior in our community.\n\nFor more information, see the [.NET Foundation Code of Conduct](https://dotnetfoundation.org/code-of-conduct).\n\n## Credits\n\nPart of the code is based on work done by OpenCover team https://github.com/OpenCover\n\n## License\n\nThis project is licensed under the MIT license. See the [LICENSE](LICENSE) file for more info.\n\n## Supported by the [.NET Foundation](https://dotnetfoundation.org/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftonerdo%2Fcoverlet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftonerdo%2Fcoverlet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftonerdo%2Fcoverlet/lists"}