Unit test coverage fail when other information(duplications, code smell) is working fine

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    -I use SonarScanner 4.0, SonarQube 7.1 on Azure Devops connection for an .NET project written in Visual Studio 2019
  • what are you trying to achieve
    I try to see my code coverage and the number of my unit tests after the build. Even if i have a bunch of unit tests in my project, in Sonarqube screen of my project it is shown %0.0 coverage and no info about the number of unit tests. Although, other information about code smell or duplication is working well.
  • what have you tried so far to achieve this
    I tried to check if there is a problem in tasks during the build. The tasks are created and sorted in the order as it is mentioned here, https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-azure-devops/
    I checked my connection between Azure and Sonarqube, there is no problem since the values of code smell is working well and also other projects using the same connection has no problem.
    I tried to add this command in the additional parameters to the scanner:

sonar.cs.vscoveragexml.reportsPaths=**/*.coveragexml

I tried to check the log report of run code analysis task of SonarScanner. There in no error but there is only this warning as follows:
sonar_error

I will be glad if someone may help me, thanks a lot :slight_smile:

hi @Genco_Cosgun and welcome to this community forum!

could you please share the verbose output of the END step command (please run SonarScanner.MSBuild.exe begin /k:"MyProject" /d:sonar.verbose=true as the BEGIN step, and please attach the output of END step)

  • I imagine for the DevOps integration you need to add the parameter sonar.verbose=true in the Prepare Analysis Configuration and give us the logs from the Run Code Analysis

Also, can you please share

  • what code coverage tool you are using?
  • are you providing the path to the code coverage report in the Prepare Analysis Configuration ?
  • between the Prepare Analysis Configuration and the Run Code Analysis , are you generating the code coverage report using your code coverage tool?

To better understand how the dotnet scan works, please read

The extension embeds its own version of the SonarScanner for MSBuild.