SonarQube Code Coverage Issue for a DotNet Core 3.1 Web Service

Hi,

We use SonarQube in Azure DevOps pipeline. We use the tasks SonarQubePrepare@4, SonarQubeAnalyze@4, and SonarQubePublish@4.

In the pipeline, we first execute SonarQubePrepare@4, build solution, and run unit tests next. In running the unit tests, we include the options ‘–collect “Code Coverage” --logger trx’ in dotnet test command line. Next we run SonarQubeAnalyze@4 for processing the code coverage data, and then finally run SonarQubePublish@4 to publish the data to SonarQube website.

One of the component is a dotnet core 3.1 web service. It contains several projects. Most of them have data populated in SonarQube web site, except a biggest major one. We are sure this project has code coverage data collected in unit tests. This is based on that we also convert the data to Cobertura.xml, and eventually we generate the html report.

Do we have any known issue about this? We inspected the pipeline log and found this. Say this service has main assembly web.api.service. Dotnet build command produces both web.api.service.dll and web.api.service.exe. In the log of SonarQubeAnalyze@4 we did text search for both binaries. We only found web.api.service.exe, but not web.api.service.dll. Looks like web.api.service.dll is not analyzed. On the other hand web.api.service.exe is just a wrapper, does not contain all the classes and stuffs. We think this is probably why the main project is missing in the web site.

Question: how can we fix this? Is there a way to tell the analyzer not to skip web.api.service.dll?

Really appreciate,

Chun-Yen

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
  • what are you trying to achieve
  • what have you tried so far to achieve this

Folks,

Later I found this link Analysis of product projects vs. test projects · SonarSource/sonar-scanner-msbuild Wiki · GitHub, and found our main project has references to test frameworks/assemblies such as MSTest.TestAdapter, MSTest.TestFramework, and Moq. The problem is resolved after removing those references.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.