I'm working on dotnet core project withd VS code inside a linux machine.
following below blog to generate coverage report: https://www.hanselman.com/blog/AutomaticUnitTestingInNETCorePlusCodeCoverageInVisualStudioCode.aspx
as mentioned there Im passing dotnet test arguments as below:
dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=lcov /p:CoverletOutput=./lcov.info
and expecting to lcov.info file to be generated, but it doesn't.
am I missing anything here?
ps: I have this package already included
<PackageReference Include="coverlet.collector" Version="1.3.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
I use to have the exact problem. Hanselman's guide never explicitly instructs the reader that the package
coverlet.msbuild
is required to instruct .NET to collect code coverage using the/p:
syntax. Includecoverlet.msbuild
in a test project by executing the following command inside the test project folder:The test project's
*.csproj
file should include a statement similar to the following:With this fix, VSCode's Coverage Gutters extension works out of the box for me when I run the exact same command as you posted.