I wrote NUnit tests to test .NET code. Now I want to see my coverage statistics in VS Code.
Is there any way to get visual/textual coverage analysis for .NET unit tests in VS Code?
Maybe there is some good extension for that?
I wrote NUnit tests to test .NET code. Now I want to see my coverage statistics in VS Code.
Is there any way to get visual/textual coverage analysis for .NET unit tests in VS Code?
Maybe there is some good extension for that?
Currently, I don't know any extensions for that in VS Code. But I found another way to see coverage stats in VS Code.
All you need to do is:
Install .NET report generator in terminal with command:
dotnet tool install -g dotnet-reportgenerator-globaltoolAdd Coverlet MS build package from NuGet to testing project
dotnet add package coverlet.msbuildRun dotnet tests from terminal with command:
dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=lcov /p:CoverletOutput=lcov.infoAdd configuration to
tasks.jsonfile in.vscodefolder (If file doesn't exist create new one):Launch task in VS Code by pressing
Ctrl + Shift + Pand executingTasks: Run taskcommand.And then press
Generate coverage statsIn your test project should appear
covstatsfolder which containindex.htmlfile. With right mouse button clickShow previewon that file. Coverage analysis will appear.Creds to: https://jasonwatmore.com/net-vs-code-xunit-setup-unit-testing-code-coverage-in-aspnet-core .