.Net SonarQube Analysis - Multiple Unit Tests

Versions

  • SonarQube 9.9
  • Using Azure DevOps tasks - latest versions

SonarQube Deployment Method
Deployed as a VM

Trying to Achieve
We have a project with multiple Unit Test folders which are executed successfully generating 2 files but stored in 2 locations for a total of 4 files - but when the analysis is done, it only picks up 1 file of the 4 when it should pick up 2 of them (2 unique files)

Tried so far
Tried to adjust how the analysis is done, where the files are stored but it still only picks up 1 file even if it sees the two files in the same folder

Output below where it found 2 unique files over 2 locations but only has coverage of one file in SQ UI

20:49:58.623  Writing processing summary to C:\a\1\.sonarqube\out\ProjectInfo.log
Calling the TFS Processor executable...
Executing file C:\a\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\5.15.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.TFSProcessor.exe
  Args: ConvertCoverage C:\a\1\.sonarqube\conf\SonarQubeAnalysisConfig.xml C:\a\1\.sonarqube\out\sonar-project.properties 
  Working directory: C:\a\1
  Timeout (ms):-1
  Process id: 6076
Attempting to locate the CodeCoverage.exe tool...
Attempting to locate the CodeCoverage.exe tool using setup configuration...
Code coverage command line tool: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe
Fetching code coverage report information from TFS...
Attempting to locate a test results (.trx) file...
Looking for TRX files in: C:\a\1\TestResults
No test results files found
Did not find any binary coverage files in the expected location.
Falling back on locating coverage files in the agent temp directory.
Searching for coverage files in C:\a\_temp
All matching files: count=4
	C:\a\_temp\6ebca9bb-b6d3-413c-996e-ce8e78f83406\AzDevOps_win2022b0004Y9_2023-09-18.20_49_51.coverage
	C:\a\_temp\AzDevOps_win2022b0004Y9_2023-09-18_20_49_34\In\win2022b0004Y9\AzDevOps_win2022b0004Y9_2023-09-18.20_49_33.coverage
	C:\a\_temp\AzDevOps_win2022b0004Y9_2023-09-18_20_49_53\In\win2022b0004Y9\AzDevOps_win2022b0004Y9_2023-09-18.20_49_51.coverage
	C:\a\_temp\f49164a3-c851-4164-9465-7b8b4a8b227e\AzDevOps_win2022b0004Y9_2023-09-18.20_49_33.coverage
Unique coverage files: count=2
	C:\a\_temp\6ebca9bb-b6d3-413c-996e-ce8e78f83406\AzDevOps_win2022b0004Y9_2023-09-18.20_49_51.coverage
	C:\a\_temp\AzDevOps_win2022b0004Y9_2023-09-18_20_49_34\In\win2022b0004Y9\AzDevOps_win2022b0004Y9_2023-09-18.20_49_33.coverage
Executing file C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe
  Args: analyze /output:C:\a\_temp\6ebca9bb-b6d3-413c-996e-ce8e78f83406\AzDevOps_win2022b0004Y9_2023-09-18.20_49_51.coveragexml C:\a\_temp\6ebca9bb-b6d3-413c-996e-ce8e78f83406\AzDevOps_win2022b0004Y9_2023-09-18.20_49_51.coverage 
  Working directory: C:\a\_temp\6ebca9bb-b6d3-413c-996e-ce8e78f83406
  Timeout (ms):60000
  Process id: 676
CodeCoverage.exe is deprecated. Use dotnet-coverage global tool or Microsoft.CodeCoverage.Console instead. Some features of CodeCoverage.exe will be removed in next release of Visual Studio.


Process returned exit code 0
Executing file C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe
  Args: analyze /output:C:\a\_temp\AzDevOps_win2022b0004Y9_2023-09-18_20_49_34\In\win2022b0004Y9\AzDevOps_win2022b0004Y9_2023-09-18.20_49_33.coveragexml C:\a\_temp\AzDevOps_win2022b0004Y9_2023-09-18_20_49_34\In\win2022b0004Y9\AzDevOps_win2022b0004Y9_2023-09-18.20_49_33.coverage 
  Working directory: C:\a\_temp\AzDevOps_win2022b0004Y9_2023-09-18_20_49_34\In\win2022b0004Y9
  Timeout (ms):60000
  Process id: 5488
CodeCoverage.exe is deprecated. Use dotnet-coverage global tool or Microsoft.CodeCoverage.Console instead. Some features of CodeCoverage.exe will be removed in next release of Visual Studio.

Output below where it found both files in the same location but SQ still doesn’t show coverage in the UI for one of them

Calling the TFS Processor executable...
Attempting to locate the CodeCoverage.exe tool...
Attempting to locate the CodeCoverage.exe tool using setup configuration...
Code coverage command line tool: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe
Fetching code coverage report information from TFS...
Attempting to locate a test results (.trx) file...
Looking for TRX files in: C:\a\1\TestResults
No test results files found
Did not find any binary coverage files in the expected location.
Falling back on locating coverage files in the agent temp directory.
Searching for coverage files in C:\a\_temp
All matching files: count=4
	C:\a\_temp\AzDevOps_win2022b0004WI_2023-09-18_14_50_46\In\win2022b0004WI\AzDevOps_win2022b0004WI_2023-09-18.14_50_44.coverage
	C:\a\_temp\AzDevOps_win2022b0004WI_2023-09-18_14_51_05\In\win2022b0004WI\AzDevOps_win2022b0004WI_2023-09-18.14_51_03.coverage
	C:\a\_temp\c0d1697e-b47a-42e7-b914-b64484db6f35\AzDevOps_win2022b0004WI_2023-09-18.14_50_44.coverage
	C:\a\_temp\f01eebe4-cba5-4260-90ee-b5ed1217c3a7\AzDevOps_win2022b0004WI_2023-09-18.14_51_03.coverage
Unique coverage files: count=2
	C:\a\_temp\AzDevOps_win2022b0004WI_2023-09-18_14_50_46\In\win2022b0004WI\AzDevOps_win2022b0004WI_2023-09-18.14_50_44.coverage
	C:\a\_temp\AzDevOps_win2022b0004WI_2023-09-18_14_51_05\In\win2022b0004WI\AzDevOps_win2022b0004WI_2023-09-18.14_51_03.coverage
Executing file C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe
  Args: analyze /output:C:\a\_temp\AzDevOps_win2022b0004WI_2023-09-18_14_50_46\In\win2022b0004WI\AzDevOps_win2022b0004WI_2023-09-18.14_50_44.coveragexml C:\a\_temp\AzDevOps_win2022b0004WI_2023-09-18_14_50_46\In\win2022b0004WI\AzDevOps_win2022b0004WI_2023-09-18.14_50_44.coverage 
  Working directory: C:\a\_temp\AzDevOps_win2022b0004WI_2023-09-18_14_50_46\In\win2022b0004WI
  Timeout (ms):60000
  Process id: 3348
CodeCoverage.exe is deprecated. Use dotnet-coverage global tool or Microsoft.CodeCoverage.Console instead. Some features of CodeCoverage.exe will be removed in next release of Visual Studio.


Process returned exit code 0
Executing file C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe
  Args: analyze /output:C:\a\_temp\AzDevOps_win2022b0004WI_2023-09-18_14_51_05\In\win2022b0004WI\AzDevOps_win2022b0004WI_2023-09-18.14_51_03.coveragexml C:\a\_temp\AzDevOps_win2022b0004WI_2023-09-18_14_51_05\In\win2022b0004WI\AzDevOps_win2022b0004WI_2023-09-18.14_51_03.coverage 
  Working directory: C:\a\_temp\AzDevOps_win2022b0004WI_2023-09-18_14_51_05\In\win2022b0004WI
  Timeout (ms):60000
  Process id: 5848
CodeCoverage.exe is deprecated. Use dotnet-coverage global tool or Microsoft.CodeCoverage.Console instead. Some features of CodeCoverage.exe will be removed in next release of Visual Studio.

So I’ve tested further and it seems that the 2 coverage files are being handled. It seems that because the files are merged to into one, we only see coverage for “one” of the src projects in SQ.

Is there a way to see a split of coverage between the two different projects “application” and “UI” or is this how it is expected that the coverage would be presented?

I tested running each set of unit tests separately but the coverage is always presented under the “application” line, even when testing the “UI” on it’s own.