Code Coverage not showing in Sonar Cloud, but does in VSTS build

dotnet
vsts

(John Bateman) #1

I am not able to see code coverage in Sonar Cloud. We have a master and develop branch in Sonar Cloud with 0.0% CC. However, in our VSTS build, we see as the build succeeds, 99.92% code coverage for blocks and 99.77% for lines.

Our app is build targeting dotnet Core 2.0 using docker containers on Linux.
Our build runs dotnet core restore, build and test tasks as well as Visual Studio Test task (with code coverage enabled). This allows us to see the code coverage in the VSTS build result, but when we run the tasks to run code analysis and publish to Sonar Cloud, we see the Bugs, Vulnerabilities and Smells accurately but 0.0% coverage. Sonar Cloud also sees the 86 unit tests in the dashboard. Finally the VSTS Build allows us to download the .coverage file.

Are we missing a step to send this to Sonar Cloud? Is there additional parameters we can use to get this to work?

Thanks for your help!


(Fabrice Bellingard) #2

Hi John, maybe you will find some useful information on the following doc page: Code Coverage Results Import (C#, VB.NET). For instance, I see the following warning which might help:

.Net Core
For projects using the roslyn based project system, vstest coverage requires Full to be set on both the unit test projects and the production projects. For more information, please refer to https://github.com/Microsoft/vstest/issues/800


(John Bateman) #3

Thank you! This was the key:

vstest coverage requires Full to be set on both the unit test projects and the production projects