Coverage not reported to SonarQube

Hello,
I’m using SonarQube version 7.7.0.23042 Developer Edition into AzureDevops 2019 Update 1 RC. I don’t know why but SonarQube does not report coverage for my .Net Code. I have followed also this topic to generate xml or trx coverage report

Looks that files are retrieved but when I go on my SonarQube server does not show me coverage (making failing the quality gate for rules on code coverage). Issues, Vulnerability and code smells are well reported, also line changes.

Attached DEBUG logs of my build pipeline
https://drive.google.com/open?id=1lix6A9Sz6Me3GMiIWB5rYECbOCBJAhV1

Looks that only where found only codecoverage for one project:

2019-07-31T06:23:33.1128829Z 08:23:33.107 INFO: Sensor C# Tests Coverage Report Import [csharp]
2019-07-31T06:23:33.8317433Z 08:23:33.825 INFO: Parsing the Visual Studio coverage XML report C:\Agent2\_work\202\.\s\CodeCoverage.coveragexml
2019-07-31T06:23:33.9161867Z 08:23:33.904 INFO: Adding this code coverage report to the cache for later reuse: C:\Agent2\_work\202\.\s\CodeCoverage.coveragexml
2019-07-31T06:23:33.9162612Z 08:23:33.904 INFO: Parsing the Visual Studio coverage XML report C:\Agent2\_work\202\.\s\TestResults\ITS-TFS-Svc_GDC01753_2019-07-31_08_20_44\In\GDC01753\ITS-TFS-Svc_GDC01753 2019-07-31 08_20_32.coveragexml
2019-07-31T06:23:33.9376646Z 08:23:33.935 INFO: Adding this code coverage report to the cache for later reuse: C:\Agent2\_work\202\.\s\TestResults\ITS-TFS-Svc_GDC01753_2019-07-31_08_20_44\In\GDC01753\ITS-TFS-Svc_GDC01753 2019-07-31 08_20_32.coveragexml
2019-07-31T06:23:33.9477969Z 08:23:33.935 DEBUG: Found some coverage info for the file 'C:\Agent2\_work\202\s\SFA.Infra.CrossCutting.Common\ProductHelper.cs'.
2019-07-31T06:23:33.9508373Z 08:23:33.935 DEBUG: Found some coverage info for the file 'C:\Agent2\_work\202\s\SFA.Infra.CrossCutting.Common\HelperClasses\ExtractionProgress.cs'.
2019-07-31T06:23:33.9550940Z 08:23:33.951 DEBUG: Found some coverage info for the file 'C:\Agent2\_work\202\s\SFA.Infra.CrossCutting.Common\DialogService.cs'.
2019-07-31T06:23:33.9580224Z 08:23:33.951 DEBUG: Found some coverage info for the file 'C:\Agent2\_work\202\s\SFA.Infra.CrossCutting.Common\AsyncTools.cs'.
2019-07-31T06:23:33.9611782Z 08:23:33.951 DEBUG: Found some coverage info for the file 'C:\Agent2\_work\202\s\SFA.Infra.CrossCutting.Common\Extensions\IFileSystemExtensions.cs'.
2019-07-31T06:23:33.9652993Z 08:23:33.951 DEBUG: Found some coverage info for the file 'C:\Agent2\_work\202\s\SFA.Infra.CrossCutting.Common\SmartComparer.cs'.
2019-07-31T06:23:33.9677680Z 08:23:33.966 DEBUG: Found some coverage info for the file 'C:\Agent2\_work\202\s\SFA.Infra.CrossCutting.Common\Events\SalesRepProfileChanged.cs'.
2019-07-31T06:23:33.9704003Z 08:23:33.966 DEBUG: Found some coverage info for the file 'C:\Agent2\_work\202\s\SFA.Infra.CrossCutting.Common\Events\FileToOpen.cs'.
2019-07-31T06:23:33.9741323Z 08:23:33.966 DEBUG: Found some coverage info for the file 'C:\Agent2\_work\202\s\SFA.Infra.CrossCutting.Common\RoamingSettingsService.cs'.
2019-07-31T06:23:33.9776366Z 08:23:33.966 DEBUG: Found some coverage info for the file 'C:\Agent2\_work\202\s\SFA.Infra.CrossCutting.Common\HelperClasses\ArchiveExtraction.cs'.
2019-07-31T06:23:33.9807393Z 08:23:33.966 DEBUG: Found some coverage info for the file 'C:\Agent2\_work\202\s\SFA.Infra.CrossCutting.Common\ExecutionContextContainer.cs'.
2019-07-31T06:23:33.9839478Z 08:23:33.982 DEBUG: Found some coverage info for the file 'C:\Agent2\_work\202\s\SFA.Infra.CrossCutting.Common\Events\ProductImageDownloadCompleted.cs'.
2019-07-31T06:23:33.9862015Z 08:23:33.982 DEBUG: Found some coverage info for the file 'C:\Agent2\_work\202\s\SFA.Infra.CrossCutting.Common\RandomHelper.cs'.
2019-07-31T06:23:33.9896341Z 08:23:33.982 DEBUG: Found some coverage info for the file 'C:\Agent2\_work\202\s\SFA.Infra.CrossCutting.Common\Log.cs'.
2019-07-31T06:23:33.9930971Z 08:23:33.982 DEBUG: Found some coverage info for the file 'C:\Agent2\_work\202\s\SFA.Infra.CrossCutting.Common\ArchiveExtractService.cs'.
2019-07-31T06:23:33.9949648Z 08:23:33.982 DEBUG: Found some coverage info for the file 'C:\Agent2\_work\202\s\SFA.Infra.CrossCutting.Common\Events\PdfToViewInApp.cs'.
2019-07-31T06:23:33.9975720Z 08:23:33.982 DEBUG: Found some coverage info for the file 'C:\Agent2\_work\202\s\SFA.Infra.CrossCutting.Common\Events\UserLoginEvent.cs'.
2019-07-31T06:23:33.9997938Z 08:23:33.997 DEBUG: Found some coverage info for the file 'C:\Agent2\_work\202\s\SFA.Infra.CrossCutting.Common\ButtonContainer.cs'.
2019-07-31T06:23:34.0023231Z 08:23:33.997 DEBUG: Found some coverage info for the file 'C:\Agent2\_work\202\s\SFA.Infra.CrossCutting.Common\HelperClasses\DialogServiceCommand.cs'.
2019-07-31T06:23:34.0042563Z 08:23:33.997 DEBUG: Found some coverage info for the file 'C:\Agent2\_work\202\s\SFA.Infra.CrossCutting.Common\Events\CatalogSettingsUpdated.cs'.
2019-07-31T06:23:34.0068814Z 08:23:33.997 DEBUG: Found some coverage info for the file 'C:\Agent2\_work\202\s\SFA.Infra.CrossCutting.Common\LocalizableResourceService.cs'.
2019-07-31T06:23:34.0098206Z 08:23:33.997 DEBUG: Found some coverage info for the file 'C:\Agent2\_work\202\s\SFA.Infra.CrossCutting.Common\EncodingHelper.cs'.
2019-07-31T06:23:34.0139226Z 08:23:34.013 DEBUG: Found some coverage info for the file 'C:\Agent2\_work\202\s\SFA.Infra.CrossCutting.Common\Logger.cs'.
2019-07-31T06:23:34.0158893Z 08:23:34.013 DEBUG: Found some coverage info for the file 'C:\Agent2\_work\202\s\SFA.Infra.CrossCutting.Common\Events\BrandThemeImagesUpdated.cs'.
2019-07-31T06:23:34.0178336Z 08:23:34.013 DEBUG: Found some coverage info for the file 'C:\Agent2\_work\202\s\SFA.Infra.CrossCutting.Common\Events\UserLogoutEvent.cs'.
2019-07-31T06:23:34.0201984Z 08:23:34.013 DEBUG: Found some coverage info for the file 'C:\Agent2\_work\202\s\SFA.Infra.CrossCutting.Common\LogService.cs'.
2019-07-31T06:23:34.0227907Z 08:23:34.013 DEBUG: Found some coverage info for the file 'C:\Agent2\_work\202\s\SFA.Infra.CrossCutting.Common\Events\FileToSendViaEmail.cs'.
2019-07-31T06:23:34.0228543Z 08:23:34.013 INFO: Sensor C# Tests Coverage Report Import [csharp] (done) | time=906ms
2019-07-31T06:23:34.0228888Z 08:23:34.013 INFO: Sensor C# Unit Test Results Import [csharp]
2019-07-31T06:23:34.0241713Z 08:23:34.013 INFO: Parsing the Visual Studio Test Results file C:\Agent2\_work\202\s\TestResults\ITS-TFS-Svc_GDC01753_2019-07-31_08_20_44.trx
2019-07-31T06:23:34.0460175Z 08:23:34.044 INFO: Sensor C# Unit Test Results Import [csharp] (done) | time=31ms

Hi,

I saw in the logs that you provide the additional property ‘sonar.cs.vscoveragexml.reportsPaths=**/*.coveragexml’

This is need if and only if you convert the trx files to coveragexml files on you own, with custom features.

If you want to only provide trx files, then the scanner will convert them for you, so you can simply remove this property, and all your trx files shall be discovered.

Hi @mickaelcaro,
yes checking the logs, also SonarSource did this job then do to myself is useless.

Anyway, I found the issue. It is related on the configuration of the projects. Setting the DebugType to Full in the csproj.

<DebugType>Full</DebugType>

Now it works well.

Please add it to the documentation, because without this information code coverage does not work.

Hi Luigi,

Please share the steps to get code coverage. I’m also having same problem. I can see unit test cases in sonarqube but code coverage is showing 0.0%

Thanks in advance

Hi @venkat255,
I start supposing that you have your pipeline that prepares SonarQube, runs the UnitTest and publishes the result on the server.

My issue was related to project settings, then right-click on the project that is under test (not the UnitTest project), Build section, Advanced, and set DebugType to Full

Pay attention that this value is set for the configuration that you are building the application (Debug or Release or custom one).

Let me know if it solve your issue.

It suffices to set the Debugging information to pdb only.