{"id":22047258,"url":"https://github.com/romanx/cake.coverlet","last_synced_at":"2025-04-09T13:07:26.670Z","repository":{"id":45197367,"uuid":"138924785","full_name":"Romanx/Cake.Coverlet","owner":"Romanx","description":"Coverlet extensions for Cake Build","archived":false,"fork":false,"pushed_at":"2024-03-09T15:51:49.000Z","size":77,"stargazers_count":40,"open_issues_count":4,"forks_count":15,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-02T11:06:33.264Z","etag":null,"topics":["build","cake","coverage","coverlet","script"],"latest_commit_sha":null,"homepage":null,"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/Romanx.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"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-06-27T19:33:03.000Z","updated_at":"2024-03-06T11:41:47.000Z","dependencies_parsed_at":"2023-01-24T17:31:41.972Z","dependency_job_id":null,"html_url":"https://github.com/Romanx/Cake.Coverlet","commit_stats":{"total_commits":40,"total_committers":8,"mean_commits":5.0,"dds":0.25,"last_synced_commit":"7dcf4ccc3830969ebac66abd6727ccc90dba203e"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Romanx%2FCake.Coverlet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Romanx%2FCake.Coverlet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Romanx%2FCake.Coverlet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Romanx%2FCake.Coverlet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Romanx","download_url":"https://codeload.github.com/Romanx/Cake.Coverlet/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248045231,"owners_count":21038553,"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":["build","cake","coverage","coverlet","script"],"created_at":"2024-11-30T13:26:51.849Z","updated_at":"2025-04-09T13:07:26.653Z","avatar_url":"https://github.com/Romanx.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cake.Coverlet\n\n[![Build status](https://ci.appveyor.com/api/projects/status/pr3lyh3baynax8gx/branch/master?svg=true)](https://ci.appveyor.com/project/Romanx/cake-coverlet/branch/master)\n[![NuGet version](https://img.shields.io/nuget/v/Cake.Coverlet.svg)](https://www.nuget.org/packages/Cake.Coverlet/)\n\n## Usage\nIn order to use the addin please make sure you've included Coverlet in the project you wish to cover and add the following to your cake build file\n```csharp\n#addin nuget:?package=Cake.Coverlet\n```\n\nYou can also install coverlet as a global tool on your machine or with the [Cake.DotNetTool.Module](https://github.com/cake-contrib/Cake.DotNetTool.Module) and run the command separately from MSBuild.\n\n**Note:** Works with Coverlet 2.1.1 and up\n\nThen use one of the following snippets\n\n```csharp\nTask(\"Test\")\n    .IsDependentOn(\"Build\")\n    .Does\u003cMyBuildData\u003e((data) =\u003e\n{\n    var testSettings = new DotNetTestSettings {\n    };\n\n    var coverletSettings = new CoverletSettings {\n        CollectCoverage = true,\n        CoverletOutputFormat = CoverletOutputFormat.opencover,\n        CoverletOutputDirectory = Directory(@\".\\coverage-results\\\"),\n        CoverletOutputName = $\"results-{DateTime.UtcNow:dd-MM-yyyy-HH-mm-ss-FFF}\"\n    };\n\n    DotNetTest(\"./test/My.Project.Tests/My.Project.Tests.csproj\", testSetting, coverletSettings);\n}\n```\n\nOr for when installed as a tool:\n\n```csharp\nTask(\"Test\")\n    .IsDependentOn(\"Build\")\n    .Does\u003cMyBuildData\u003e((data) =\u003e\n{\n    var coverletSettings = new CoverletSettings {\n        CollectCoverage = true,\n        CoverletOutputFormat = CoverletOutputFormat.opencover,\n        CoverletOutputDirectory = Directory(@\".\\coverage-results\\\"),\n        CoverletOutputName = $\"results-{DateTime.UtcNow:dd-MM-yyyy-HH-mm-ss-FFF}\"\n    };\n\n    // I want to specify the specific dll file and the project exactly.\n    Coverlet(\n        \"./test/My.Project.Tests/bin/Debug/net46/My.Project.Tests.dll\", \n        \"./test/My.Project.Tests/My.Project.Tests.csproj\", \n        coverletSettings);\n\n    // I want to specify just the project file and the dll can be\n    // inferred from the name of the project file.\n    Coverlet(\n        \"./test/My.Project.Tests/My.Project.Tests.csproj\", \n        coverletSettings);\n\n    // I want to specify just the project directory, we will discover\n    // any proj file in the directory (take the first) and infer the \n    // name from the found project.\n    Coverlet(\n        \"./test/My.Project.Tests\",\n        coverletSettings);\n}\n```\n\nThere is an additional api exposed for transforming the output name of the coverage file at the time of calling `dotnet test`.\nThis transform function follows the form `Func\u003cstring, string\u003e` being passed the `CoverletOutputName` and the return is used for the filename.\n\n```csharp\nTask(\"Test\")\n    .IsDependentOn(\"Build\")\n    .Does\u003cMyBuildData\u003e((data) =\u003e\n{\n    var testSettings = new DotNetTestSettings {\n    };\n\n    var coverletSettings = new CoverletSettings {\n        CollectCoverage = true,\n        CoverletOutputFormat = CoverletOutputFormat.opencover,\n        CoverletOutputDirectory = Directory(@\".\\coverage-results\\\"),\n        CoverletOutputName = $\"results\"\n        OutputNameTransformer = (fileName, directory) =\u003e $@\"{directory}\\{fileName}-HelloWorld\"\n    };\n\n    DotNetTest(\"./test/Stubble.Core.Tests/Stubble.Core.Tests.csproj\", testSetting, coverletSettings);\n}\n```\n\nWe expose a default transformer for the standard practice of appending the current datetime to the file as `WithDateTimeTransformer()`\n\nIf you wish to only change the directory that the output is written to then set the `CoverletOutputDirectory` and the filename handling will be done by coverlet as usual.\n\n## Setting more than one output format\nYou can support multiple coverlet formats by providing them like this:\n\n```csharp\nvar coverletSettings = new CoverletSettings {\n        CollectCoverage = true,\n        CoverletOutputFormat = CoverletOutputFormat.opencover | CoverletOutputFormat.cobertura,\n        CoverletOutputDirectory = Directory(@\".\\coverage-results\\\"),\n        CoverletOutputName = $\"results-{DateTime.UtcNow:dd-MM-yyyy-HH-mm-ss-FFF}\"\n    };\n```\n\nOr by using the method on the settings class like this:\n```csharp\nvar coverletSettings = new CoverletSettings {\n        CollectCoverage = true,\n        CoverletOutputFormat = CoverletOutputFormat.opencover,\n        CoverletOutputDirectory = Directory(@\".\\coverage-results\\\"),\n        CoverletOutputName = $\"results-{DateTime.UtcNow:dd-MM-yyyy-HH-mm-ss-FFF}\"\n    }.WithFormat(CoverletOutputFormat.cobertura);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fromanx%2Fcake.coverlet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fromanx%2Fcake.coverlet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fromanx%2Fcake.coverlet/lists"}