No code coverage in SonarCloud (all seems to be configured correctly)

  • Azure DevOps
  • SonarCloud, in Azure Devops we have SonarCloud Extension version 1.8.2 (Latest)
  • The project in SonarCloud is Private

I added/configured the SonarCloud tasks in our Build pipeline, i see test and code coverage running during the VSO proces, i also see a test and codecoverage tab in VSO. And in VSO it contains data (result of the tests, and a % of codecoverage).

But i don’t see the code coverage show up in SonarCloud. It stays at 0.0%.

During the “Run Code Analysis” step i do see the following lines in the log:

So it does see the created files from the test/codecoverage step? I’m pulling my hair out at the moment :wink:

What can/must i do to see the codecoverage in SonarCloud.

Thanks,
Dennis

1 Like

Hi,

Do you have vstest.console.exe somewhere on the machine running the build ?

Thanks.

Mickaël

Mickael,

Yeah i’m running the builds on a (own) hosted build machine. I see VSTest running, i also see the created files (test & coverage) show up in the SonarCloud code analyses task, but it isn’t showing up.

Or do you mean something else ?

Dennis

Ah, yes, sorry, i was in fact talkin about the CodeCoverage tool provided with Visual Studio Enterprise only.

You need this tool on your machine so that the scanner will be able to effectively convert your *.coverage to *.coveragexml, only understandable files by SonarCloud for code coverage (using vstest tool)

I agree that there is not that much log if we don’t find the tool (i didn’t see them on your posted logs)

Can you confirm that you do / don’t have this tool ?

Thanks.

Mickael,

I checked the local install and see that “vstest.console” is present. I also checked that the local install has a valid license.
When i check the VSO VSTest task, i see the following output.
image

The SonarClound “Code analysis contains”
image

Is there anymore information you require?

Dennis

Do you have this executable “CodeCoverage.exe” located under : “\Enterprise\Team Tools\Dynamic Code Coverage Tools” ?

Mickael,

Yes it’s present.

1 thing i do see in the log is:
14:33:22.144 Found corresponding Binary-to-XML conversion output file for g:\work\29\s\TestResults\vb-admin_BDBUILDAGENT01_2019-08-29_15_51_48\In\BDBUILDAGENT01\vb-admin_BDBUILDAGENT01 2019-08-29 15_51_33.coverage, no conversion will be attempted.

Which is kinda strang regarding your earlier remark that there needs to be a conversion from *.coverage => *.coveragexml

Is there anything i can do to give you more data with which you can pinpoint the issue?

Dennis

Ok so given your log output, i think i understood, at least why you get the message above.

You have two ways to give to SonarCloud your coverage file (at least by the way you are using/providing it)

  • Just run the vs test task, it will output, if you enable code coverage, a .trx and a .coverage files. That way, the Scanner for MSBuild will detect them, and try to convert the .coverage file to .coveragexml
  • Run the vs test task and convert the coverage file by yourself, before the “Run code analysis” task. That way, you choose provide the following additional property “sonar.cs.vscoveragexml.reportsPaths” in the “Prepare analysis configuration” task, so that the Scanner will discover them and parse them, otherwise, and that’s the reason why you get the message, no action will be done on the coveragexml file.

Can you try either adding the property with the path to your coveragexml files, or just not do the conversion before the Run Code Analysis task, and let us know ?

Thanks.

Mickaël

Mikael,

I removed the property, and rerun the build pipeline.
In the log i see:

a little bit down i see

but nothing shows up in SonarCloud, it there a log in SonarCloud which could identify the issue?

If required/helpful we could setup a teamviewer session in with i can directly show you the required information/settings. Let me know

Cheers, Dennis

Can you provide us the full log of your Run Code Analysis task please, and with debug enabled (i’ll be perfect). Of course with redacted secure things if you have to !

Thanks in advance.

Mickaël

Mickael,

Sonar debugging (if so how can i set it), or VSO build option system.debug == true ?

Dennis

Try with system.debug = true (it should add a debug flag as well while invoking the Scanner CLI)

Mickael,

I encluded an extract of the log, hope it’s enough, if not let me know, i kinda tried to remove the long list of files.

SonarCloud Log.txt (47.4 KB)

Dennis

Thank you.

We’re going to check this internally and come back to you.

Do you see any kind of warning showing up when you select the branch in the dropdown (arrow next to “master” in SonarCloud ?

Mickael,

No i don’t see a warning.
image

I do need to mention that i renamed master => develop, like described here: How to change main branch

Dennis

Mickael,

I noticed (in some of the treads) that there was a new version of the Azure DevOps plugin release, i checked if it changed anything, but in my case the coverage still isn’t showing up.
Have you found anything in the logs? Or have found something else?
Is there anything i can check (recreate project (or test in a new project) ?

Cheers,
Dennis

To all who encounter this issue, with help of @mickaelcaro and some updates to the SonarCloud vso tasks, we found the issue.

In my case the property “/p:PathMap” in the build task caused it, when removed i do see the code coverage showing up in SonarCloud.

Hi Mickael & Dennis

I am facing the same issue, in vstest code coverage is disable when enable the build is failing.

Can you please help me.

If you want i can give you the logs.

Atul