Hello. I hope I am posting this in the right channel. I am new to using SonarQube. I am trying to deploy coverage report to SonarQube (Enterprise Edition Version 9.9) as part of my Azure pipeline. Coverage reports are generated by Visual Studio (application being scanned is an asp.net web site using C#). When the pipeline finished, I can see that the SQ report reports the correct number of Unit Tests but the Code Coverage percent is 0% (coverage should be much higher). I am trying to get SonarQube to accurately report the Code Coverage percentage. Relevant pipeline script:
- task: SonarQubePrepare@5
displayName: 'Prepare SQ'
inputs:
SonarQube: 'SonarQube'
scannerMode: 'MSBuild'
projectKey: 'someKey'
extraProperties:
sonar.verbose=true
- task: VSBuild@1
displayName: 'Build'
inputs:
solution: '$(solution)'
configuration: '$(buildConfiguration)'
-task: DotNetCoreCLI@2
displayName: Run Server Unit Tests
inputs:
command: 'test'
projects: **/*myproject.ProjectTests.csproj'
arguments: '--collect "Code Coverage"'
-task: CopyFiles@2
inputs:
SourceFolder: '$(Agent.HomeDirectory)\_work\_temp'
Contents: '**'
TargetFolder: '$(Common.TestResultsDirectory)'
This code will generate .trk file (about 137kb) and folder that has a *.coverage and *.coveragexml files in the _temp folder of my build server and copies the files to "C:/MyAgent/_work/1/TestResults folder. I can also see in the Run Server Unit Test task that the Unit Tests ran successfully (and the number of passed tests).
In the SonarQube Analysis task, there are a couple of things that caught my eye:
-
The output states that its “Parsing the Visual Studio Coverage XML Report” and that it is "Adding this code coverage report (*.coveragxml) to the cache for later use. It also provides Coverage Report Statistics (56 files, 0 main files with coverage, 56 test files, 0 project excluded files and 0 other files). It then states that “Code Coverage Report doesn’t contain any coverage data for the included file” . It then gives a link for support, which I tried to do but has not worked.
-
After this warning, I see a list of CS files that are listed as “Missing blame information”
All tasks complete without error. But, when I log into SQ, I can see that the total number of Unit Tests are correct but the Code Coverage percentage is wrong. Can someone assist with how to get SQ to accurately report Code Coverage?
thanks!