Kushan
Kushan

Reputation: 1270

Sonarqube not measuring code coverage from TFS 2017 Build

I've set up SonarQube and integrated it with our on-prem TFS build server, which is working fine except for one feature - code coverage. For some reason, it's not detecting any code coverage results even though the second SonarQube step is picking up .trx files.

The "code coverage enabled" tickbox is ticked and within TFS, I am getting code coverage metrics:

enter image description here

However, SonarQube isn't displaying coverage:

enter image description here

When I check the build logs, it does appear that SonarQube is picking up the necessary file:

enter image description here

However it's just not processing coverage. What could I have missed?

TFS is Version 15.112.26307.0

SonarQube is version 6.5

Upvotes: 4

Views: 1607

Answers (1)

Andy Li-MSFT
Andy Li-MSFT

Reputation: 30372

There is a regression bug in either the Scanner for MSBuild or the VSTS extension that cause code coverage file to not being automatically imported if the user doesn't specify the report path.

As mentioned in the linked thread, you can fix this issue by adding /d:sonar.cs.vscoveragexml.reportsPaths="**\*.coveragexml" into the Advanced > Additional Settings of the SonarQube Scanner for MSBuild - Begin Analysis (new) task.

Note : make sure you have enabled the Code Coverage Enabled in Test Assemblies step.

enter image description here

Upvotes: 6

Related Questions