Handling Multiple Coverage Reports

sonarcloud
vsts
coverage
csharp

(Jayesh Coupland) #1

Hello!

I’m trying to get the right coverage data out of my .Net Core C# project. The problem seems to be that I have both unit and component tests that I run separately. Each produces a trx file and corresponding coverage data. The Sonar scanner then seems to have a problem with the multiple files and doesn’t report the coverage:

2018-08-23T07:22:42.9369196Z Post-processing started.
2018-08-23T07:22:43.1123050Z 07:22:43.111  Fetching code coverage report information from TFS...
2018-08-23T07:22:43.1142541Z 07:22:43.113  Attempting to locate a test results (.trx) file...
2018-08-23T07:22:43.1555272Z 07:22:43.154  Looking for TRX files in: D:\a\1\TestResults
2018-08-23T07:22:43.1563841Z 07:22:43.155  07:22:43.155  WARNING: More than one test result file was found: expecting to find only one. Results files: D:\a\1\TestResults\VssAdministrator_factoryvm-az243_2018- 08-23_07_22_31.trx, D:\a\1\TestResults\VssAdministrator_factoryvm-az243_2018-08-23_07_22_36.trx
2018-08-23T07:22:43.1579605Z 07:22:43.155  Attempting to locate a test results (.trx) file...
2018-08-23T07:22:43.1930718Z 07:22:43.192  Looking for TRX files in: D:\a\1\TestResults
2018-08-23T07:22:43.1931237Z 07:22:43.192  07:22:43.192  WARNING: More than one test result file was found: expecting to find only one. Results files: D:\a\1\TestResults\VssAdministrator_factoryvm-az243_2018- 08-23_07_22_31.trx, D:\a\1\TestResults\VssAdministrator_factoryvm-az243_2018-08-23_07_22_36.trx

Is there any way I can configure the Sonar Scanner to recognise both results and coverage files and to amalgamate coverage data from both?

Thanks


(Amaury Levé) #2

Hi @Jayesh_Coupland

This is currently not possible but I have created a ticket so that we handle this use case (see here).

In the meantime, the only thing you could do is to merge the different reports.


(Jayesh Coupland) #3

Ah, thanks! I’ll look into merging the reports then.


(Richard Johnston) #4

Hi,

I’m running into this same issue, multiple trx and coverage files still seems to produce zero coverage so I’m assuming the fix hasn’t made its way through yet?

@Jayesh_Coupland Did you succeed in merging coverage files in the end?


(Andrei Epure) #5

@richardjohnston the fix (sonar-scanner-msbuild#560) got into the 4.5 version of Sonar Scanner for MSBuild (released on December 10th 2018).

What version of the sonar scanner for msbuild are you using? could you please update to the latest and try again?


(Richard Johnston) #6

Hi @Andrei_Epure,

We are using the Sonarcloud extension for Azure DevOps which I believe is currently 1.6 and will auto update?

Will that contain the latest version of the scanner?

EDIT

Here’s the start of output from the Azure Devops task:


==============================================================================
Task : Run Code Analysis
Description : Run scanner and upload the results to the SonarCloud server.
Version : 1.6.0
Author : sonarsource
Help : This task is not needed for Maven and Gradle projects since the scanner should be run as part of the build.

More Information

==============================================================================
[command]C:\agent3_work_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.6.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe end
SonarScanner for MSBuild 4.6
Using the .NET Framework version of the Scanner for MSBuild


Regards
Richard


(Jeroen Vos) #7

I’m having the same issue. 2 test runs that both publish a TRX, then the SonarCloud MSBuild scanner only pics up the one that got published last. I’m running 1.6 as well.