Code Coverage Discrepancy

csharp
(Sven Myrin) #1

Hey all.

I have been trying to sort out why our code coverage numbers between Visual Studio and SonarQube do not agree. We have integrated SonarQube into our builds and everything seems to be working well. We build the solution in Visual Studio 2015 and then execute unit tests while gathering code coverage. We get the associated .coverage and .coveragexml files normally. The SonarQube process appears to parse the .coveragexml file and upload its contents. However, the reported code coverage values are not in line with the files generated by the testing.

For example, in this project, I see that the CustomSetting class shows 50% coverage as shown in the .coverage file and the .coveragexml file:



However, in the SonarQube report, the same class is showing 100% coverage:
Capture4
Capture3

Can someone explain why this is happening and what I can do to make the reports match one another?

SQ Version 7.6 (build 21501)

(Andrei Epure) #2

hi @smyrin and thanks for raising the point.

You can find some general information on SonarQube and the code coverage

From looking at the specific issue you are mentioning, I see that the set methods are covered and the get ones are not, I’ll try to make a repro and come back on this thread.

(Sven Myrin) #3

Thanks for the explanation. That really helped!