# .Net SonarQube Analysis - Multiple Unit Tests

**URL:** <https://community.sonarsource.com/t/net-sonarqube-analysis-multiple-unit-tests/99467>\
**Category:** SonarQube Server / Community Build\
**Tags:** dotnet, coverage\
**Created:** [September 18, 2023, 9:22pm UTC](https://community.sonarsource.com/t/net-sonarqube-analysis-multiple-unit-tests/99467 "2023-09-18T21:22:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![robertmarks](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/robertmarks/32/46140_2.png) [@robertmarks](https://community.sonarsource.com/u/robertmarks)\
**Post date:** [September 18, 2023, 9:22pm UTC](https://community.sonarsource.com/t/net-sonarqube-analysis-multiple-unit-tests/99467/1 "2023-09-18T21:22:11Z")

</div>

**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**

```auto
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**

```auto
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.

```

---

<div class="post-metadata">

**Author:** ![robertmarks](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/robertmarks/32/46140_2.png) [@robertmarks](https://community.sonarsource.com/u/robertmarks)\
**Post date:** [September 19, 2023, 8:22am UTC](https://community.sonarsource.com/t/net-sonarqube-analysis-multiple-unit-tests/99467/2 "2023-09-19T08:22:06Z")

</div>

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.

 ![image](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/3X/a/1/a1ac11b51591306979c076071e3797d679de457e.png)

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.

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [September 27, 2023, 3:21pm UTC](https://community.sonarsource.com/t/net-sonarqube-analysis-multiple-unit-tests/99467/3 "2023-09-27T15:21:53Z")

</div>

Hey there.

I’m surprised to see a `--` under Coverage for the UI project. That means that 0 lines of code have been marked as executable. What kind of files are in your UI project? Are they .NET files? Do your coverage reports actually show coverage for files listed in the UI project (you should be able to view the raw XML files to tell!)

---

<div class="post-metadata">

**Author:** ![robertmarks](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/robertmarks/32/46140_2.png) [@robertmarks](https://community.sonarsource.com/u/robertmarks)\
**Post date:** [September 28, 2023, 9:53am UTC](https://community.sonarsource.com/t/net-sonarqube-analysis-multiple-unit-tests/99467/4 "2023-09-28T09:53:49Z")

</div>

Hey Colin. The issue was related to how the csproj files were setup - specifically which NuGet packages were installed / included. Our devs have changed how this is setup and it’s all working as expected now.  
Thanks.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/system/32/31083_2.png) [@system](https://community.sonarsource.com/u/system)\
**Post date:** [October 5, 2023, 9:53am UTC](https://community.sonarsource.com/t/net-sonarqube-analysis-multiple-unit-tests/99467/5 "2023-10-05T09:53:52Z")

</div>

Closed on October 5, 2023, 9:53am UTC

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
