Code coverage is showing as 0.0% while i can see the code bugs, vulnerabillity and code smell issues

Hm, not clear what your real question is.
I’m no expert for C#, so i can’t help further with that.
Did you check all the links i posted, e.g. the guide about
[Coverage & Test Data] Generate Reports for C#, VBnet ?

You wrote

Do you ask if this works with Sonarlint plugin in Visual Studio ?

No, this is not my query “Do you ask if this works with Sonarlint plugin in Visual Studio ?”.
First i got the error as “CodeCoverage.exe” is missing, then i searched in google about this error. Then i got one solution “Agent for Visual Studio 2017” will provide code coverage.
Actually in Visual Studio professional there is no ‘Agent’ extension to get codecoverage in sonarqube.
so is there any other process to get code coverage in sonarqube.

The [Coverage & Test Data] Generate Reports for C#, VBnet has all the details.
If CodeCoverage.exe is missing, searching this community forum / the web will
bring up relevant postings.

Hi
I have run this " Run Unit Tests & Coverage".
Before i got an error like “codecoverage.exe” is missing as mentioned in below, then by installing visual studio i had this codecoverage.exe file.
Now if iam running same command then i got the error like:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow>vstest.console.exe /EnableCodeCoverage "—MyProjectDllPath—"
Microsoft ® Test Execution Command Line Tool Version 15.9.1
Copyright © Microsoft Corporation. All rights reserved.

Starting test execution, please wait…
No test is available in —MyProjectDllPath— . Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.

Attachments:
*** C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow\TestResults\0aebc646-607d-4d46-81a6-6e53b8186e25\sushma_2020-02-05 11_12_15.coverage***

Additionally, path to test adapters can be specified using /TestAdapterPath command. Example /TestAdapterPath:.

So please suggest me what to do next.

Perhaps I’m misunderstanding. “Code Coverage” reflect the % of source code for which sonar sees unit test results. That means that somewhere (Visual Studio?) you have executed a full suite of unit (method) level tests, that those results are being picked up by sonar-scanner, being stored in elasticsearch by sonarqube, and then displayed.

When I have problems like this, I like to start at the beginning and trace things.

  1. Did unit tests get made?
  2. Did they get executed?
  3. Did the results get stored?
  4. Dig the results get picked up during the sonar scan?
  5. Did the results get put into elasticsearch?

Almost always for me, the problem is either the tests didn’t get run (improper command) or the scanner failed to find them (improper sonar-project.properties.)

Good luck!

2 Likes