I’m trying to implement Code Coverage in my applications. But the results are not showing up on the sonar report. Running a script on powershell using coverlet shows the coverage as 70-80%, but does not reflect on the platform
Hi,
Welcome to the community!
Can you share your analysis logs, please?
Share the Scanner for .NET verbose logs
- Add
/d:"sonar.verbose=true"
to the…SonarScanner.MSBuild.exe
ordotnet sonarscanner
begin command to get more detailed logs- For example:
SonarScanner.MSBuild.exe begin /k:"MyProject" /d:"sonar.verbose=true"
- For example:
- “SonarQubePrepare” or “SonarCloudPrepare” task’s
extraProperties
argument if you are using Azure DevOps- For example:
- task: SonarCloudPrepare@3 inputs: SonarCloud: 'sonarcloud' organization: 'foo' scannerMode: 'dotnet' projectKey: 'foo_sonar-scanning-someconsoleapp' projectName: 'sonar-scanning-someconsoleapp' extraProperties: | sonar.verbose=true
- For example:
- The important logs are in the
END
step (i.e. SonarQubeAnalyze / SonarCloudAnalyze / “Run Code Analysis”)
Share the msbuild detailed logs
MsBuild.exe /t:Rebuild /v:d
or
dotnet build -v:d
Thx,
Ann
sonarlogs.txt (770.8 KB)
Is this the one you were referring to?
Hi,
That appears to be your build log, not your end
log.
Can you provide an end
log that is not width-constrained? This log is nearly unreadable.
Thx,
Ann
sonarendlogs.txt (287.8 KB)
Can you check this once
Hi,
I don’t see in this log any mention of a coverage report being picked up and processed. In fact, I see this:
22:42:39.650 DEBUG: 'C# Tests Coverage Report Import' skipped because one of the required properties is missing
How are you passing your coverage report in to analysis?
Ann
Hi Ann
I just follow the steps for running the analysis on my project as it is given on the SonarQube platform. Incase of dotnet core the steps are these:
dotnet tool install --global dotnet-sonarscanner
dotnet sonarscanner begin …
dotnet build
dotnet sonarscanner end
do I have to run some other commands for code coverage separately?
Thank you,
Saswati
Thank you! I’ll work on it
Hi, I have a doubt. I used coverlet for code coverage generation.
It is showing more than 60% coverage here. However in SonarQube,
, I’m getting this.
Hi,
We try to keep it to one topic per thread. Otherwise it can get messy, fast. Here, you’ve moved from coverage import, which is solved based on your screenshot, to coverage mismatch.
Ordinarily, I would ask you to create a new thread for this, but this dusty-but-still-relevant blog post should help.
If you have further questions on number discrepancies, please do create a new thread.
Thx,
Ann