using Sonarqube * Enterprise Edition * v10.7 on prem installation
I try to upload Test Coverage results ( via Azure Devops tasks ):
My configuration inside pipeline is:
- task: SonarQubePrepare@7.0.3
displayName: "Prepare analysis on SonarQube"
inputs:
SonarQube: SonarQube
scannerMode: dotnet
configMode: manual
projectKey: mishadec
projectVersion: '1.0'
extraProperties: |
sonar.inclusions=Decoder/**
sonar.cs.vstest.reportsPaths=$(Common.TestResultsDirectory)\*.trx
- task: VSTest@2
displayName: "Run Decoder tests"
inputs:
testAssemblyVer2: |
Decoder\Tests\UT.E2ETest\bin\Release\UT.E2ETest.dll
Decoder\Output\Tests\Release\UT.DCR.dll
Decoder\Output\Tests\Release\UT.ServicesAndProcess.dll
Decoder\Output\Tests\Release\UT.LynxConversion.dll
runInParallel: false
runTestsInIsolation: true
runSettingsFile: Decoder\Tests\MTATest.runsettings
otherConsoleOptions: '/collect:"Code Coverage" /platform:x64'
platform: "$(BuildPlatform)"
configuration: "$(BuildConfiguration)"
rerunFailedTests: true
codeCoverageEnabled: true
vstestLocationMethod: location
vstestLocation: $(vstestPath)
resultsFolder: $(Common.TestResultsDirectory)
- task: SonarQubeAnalyze@7.0.3
Execution of the VSTest@2 task creates a new .coverage file in random directories.
Then the SonarQubeAnalyze task produces these logs, as if everything is ok, at the end of analysis I checked SonarQube project on the server and the code coverage shows 0%, clearly it was not uploaded OR the uploaded files show zero code coverage ( I tend to think it’s the second ). What is the problem here, what is the role of .trx file ? since the sonar scanner found the coverage files and they are near empty files, it creates .coveragexml with empty content:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
The issue is in scanner not getting the right .trx or the empty generated .coverage files created by VSTest@2 task WDYT ? Because I see one of the .trx files has lots of data, the other 3 .trx files have less data.
below are the logs from SonarQubeAnalyze task
SonarScanner for MSBuild 9.0.1
Using the .NET Framework version of the Scanner for MSBuild
Post-processing started.
Calling the TFS Processor executable...
Property 'sonar.cs.vstest.reportsPaths' provided, skipping the search for TRX files in default folders...
Absolute path to coverage file: E:\Agent\_work\4\TestResults\tfs22service_PT-WIN22-46_2024-11-04_15_23_22\In\PT-WIN22-46\tfs22service_PT-WIN22-46_2024-11-04.15_23_18.coverage
Absolute path to coverage file: E:\Agent\_work\4\TestResults\tfs22service_PT-WIN22-46_2024-11-04_15_28_34\In\PT-WIN22-46\tfs22service_PT-WIN22-46_2024-11-04.15_28_30.coverage
Absolute path to coverage file: E:\Agent\_work\4\TestResults\tfs22service_PT-WIN22-46_2024-11-04_15_28_45\In\PT-WIN22-46\tfs22service_PT-WIN22-46_2024-11-04.15_28_41.coverage
Absolute path to coverage file: E:\Agent\_work\4\TestResults\tfs22service_PT-WIN22-46_2024-11-04_15_28_51\In\PT-WIN22-46\tfs22service_PT-WIN22-46_2024-11-04.15_28_49.coverage
The following code coverage attachments were found from the trx files: E:\Agent\_work\4\TestResults\tfs22service_PT-WIN22-46_2024-11-04_15_23_22\In\PT-WIN22-46\tfs22service_PT-WIN22-46_2024-11-04.15_23_18.coverage, E:\Agent\_work\4\TestResults\tfs22service_PT-WIN22-46_2024-11-04_15_28_34\In\PT-WIN22-46\tfs22service_PT-WIN22-46_2024-11-04.15_28_30.coverage, E:\Agent\_work\4\TestResults\tfs22service_PT-WIN22-46_2024-11-04_15_28_45\In\PT-WIN22-46\tfs22service_PT-WIN22-46_2024-11-04.15_28_41.coverage, E:\Agent\_work\4\TestResults\tfs22service_PT-WIN22-46_2024-11-04_15_28_51\In\PT-WIN22-46\tfs22service_PT-WIN22-46_2024-11-04.15_28_49.coverage
Not using the fallback mechanism to detect binary coverage files.
Converting coverage file 'E:\Agent\_work\4\TestResults\tfs22service_PT-WIN22-46_2024-11-04_15_23_22\In\PT-WIN22-46\tfs22service_PT-WIN22-46_2024-11-04.15_23_18.coverage' to 'E:\Agent\_work\4\TestResults\tfs22service_PT-WIN22-46_2024-11-04_15_23_22\In\PT-WIN22-46\tfs22service_PT-WIN22-46_2024-11-04.15_23_18.coveragexml'.
Converting coverage file 'E:\Agent\_work\4\TestResults\tfs22service_PT-WIN22-46_2024-11-04_15_28_34\In\PT-WIN22-46\tfs22service_PT-WIN22-46_2024-11-04.15_28_30.coverage' to 'E:\Agent\_work\4\TestResults\tfs22service_PT-WIN22-46_2024-11-04_15_28_34\In\PT-WIN22-46\tfs22service_PT-WIN22-46_2024-11-04.15_28_30.coveragexml'.
Converting coverage file 'E:\Agent\_work\4\TestResults\tfs22service_PT-WIN22-46_2024-11-04_15_28_45\In\PT-WIN22-46\tfs22service_PT-WIN22-46_2024-11-04.15_28_41.coverage' to 'E:\Agent\_work\4\TestResults\tfs22service_PT-WIN22-46_2024-11-04_15_28_45\In\PT-WIN22-46\tfs22service_PT-WIN22-46_2024-11-04.15_28_41.coveragexml'.
Converting coverage file 'E:\Agent\_work\4\TestResults\tfs22service_PT-WIN22-46_2024-11-04_15_28_51\In\PT-WIN22-46\tfs22service_PT-WIN22-46_2024-11-04.15_28_49.coverage' to 'E:\Agent\_work\4\TestResults\tfs22service_PT-WIN22-46_2024-11-04_15_28_51\In\PT-WIN22-46\tfs22service_PT-WIN22-46_2024-11-04.15_28_49.coveragexml'.
Coverage report conversion completed successfully.