Hello, did you get a solution? I have the same problem. Number of unit tests are there but no coverage.
You must add these lines to sonar.properties;
You have to generate code coverage with opencover format.
You can use command like this:
dotnet test --logger trx --results-directory $(System.DefaultWorkingDirectory)\TestResults /p:CollectCoverage=true "/p:CoverletOutputFormat=\"cobertura,opencover\""
- what is the version of SonarQube that you are using?
- what is the version of Scanner for MSBuild you are using?
- what are the commands you are running to do the analysis?
- are you running all commands from the same folder?
- what is the version of MSBuild you are using?
- what code coverage tool are you using?
You can turn on the verbose output of the command (please run
SonarScanner.MSBuild.exe begin /k:“MyProject” /d:sonar.verbose=true as the begin step), and give us the logs from the END step.
Also some docs you can refer to:
- [Coverage & Test Data] Generate Reports for C#, VB.net
You can take a look at the discussion on Code Coverage is not shown in the SonarCloud.io to make sure you run the commands from the same folder and you can check the paths inside the reports are correct.