2

For .net unit testing I installed Coverage Gutter in visual studio code.

https://marketplace.visualstudio.com/items?itemName=ryanluker.vscode-coverage-gutters.

But is not showing the line coverage.

when I press Coverage Gutter display coverage or press the "watch" option in the footer it says "Could not find coverage file"

Error:

Could not find a Coverage file! Searched for lcov.info, cov.xml, coverage.xml, jacoco.xml, coverage.cobertura.xml

Project structure

my setting.json

{

  "dotnet-test-explorer.testProjectPath": "**/*test.csproj",
  "dotnet-test-explorer.runInParallel": true,
  "coverage-gutters.showLineCoverage": true,
  "dotnet-test-explorer.testArguments": "/p:CollectCoverage=true /p:CoverletOutputFormat=lcov /p:CoverletOutput=../../lcov.info",
  "coverage-gutters.coverageBaseDir": "**",
  "coverage-gutters.coverageFileNames": [
    "lcov.info",
    "cov.xml",
    "coverage.xml",
    "jacoco.xml",
    "coverage.cobertura.xml"
  ]
}

I think the issue is in "coverage-gutters.coverageBaseDir": "**", Can anyone help me to fix the issue?

hanushi
  • 1,169
  • 2
  • 12
  • 27

1 Answers1

0

I followed this Scott Hanselman's blog and this other answer to make it work for me. Here is the summary of what is needed:

If your lcov.info file is not generated, try adding the coverlet.msbuild package to your test project and then run the tests again.

dotnet add package coverlet.msbuild

Your test arguments are correct, just ensure that it generates the lcov.info file inside the workspace folder. Coverage gutters extension can by default read lcov.info file within any workspace folder to show the coverage so you don't need to specify the coverageFileNames and coverageBaseDir settings.

prinkpan
  • 2,117
  • 1
  • 19
  • 32