C#C
C#2w ago
Aenea

VS Code code coverage exclusion

Hello,

I'm trying to exclude files from code coverage in VS Code.

The biggest problem is caused by source generated file OpenApiXmlCommentSupport.generated.cs which brings the percentage down a lot.

Additionally I'd also like to exclude EF Core Migrations folder.

I tried .runsettings file and confirmed it is recognized and used when running tests from Test Explorer, but exclusion properties don't work.

Also tried some .csproj properties which don't get picked up.

Found this issue https://github.com/microsoft/vscode-dotnettools/issues/2093 where others confirm .runsettings rules don't apply with Test Explorer coverage.
Eventually I gave up and tried to create a coverage report with coverlet but even with dotnet test -collect:"Xplat Code Coverage" the exclusion rules don't get picked up.

Not sure if .runsettings just doesn't work with VS Code Test Explorer, but if that's the case I'd like to get coverlet reports.
image.png
Was this page helpful?