Installing Coverlet
Coverlet is an open source project that produces code coverage reports.
In Visual Studio install the coverlet.collector and coverlet.msbuild NuGet package.
nuget install coverlet.collector
nuget install coverlet.msbuild
Running Coverlet Locally
dotnet test /p:CollectCoverage=true
Viewing Coverage in Visual Studio
This Visual Studio 2022 extension allows you to view coverage line by line and as a summary
https://marketplace.visualstudio.com/items?itemName=FortuneNgwenya.FineCodeCoverage
Defining the Azure Pipeline
Using the wizard follow the steps below.
Use the .NET Core SDK
Select the .NET Core SDK appropriate for your project.
Perform a .NET Restore
A restore will download the Nuget packages for your project.
Perform a .NET Build
Run the Tests
Ensure to define the arguments to collect coverage
Publish the Code Coverage
Task version 1 will be deprecated. See this post from Microsoft:
https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/publish-code-coverage-results-v2?view=azure-pipelines