SonarQube scanner not retrieving dotnet xUnit testing code coverage

Hello,

I’ve created a sonar-runner to be used inside some pipelines. It’s basically a docker image containing some a script that executes some actions depending on the program language.

Inside that project there are some example programs (test directory) as well as some language specific scanners (containing some comments inside them).

My current problem is: I cannot get code coverage on dotnet project using xUnit testing.
Every other language is working just fine as well as using NUnit testing in dotnet.

Is something missing on my configuration?

Print of the SonarQube Projects:

Versions:

  • Runner: adoptopenjdk:11-jre-hotspot
  • SonarQube: sonarqube:8.4.2-community
  • Postgres: postgres:12.2-alpine
  • coverlet.console: 1.7.2
  • dotnet-sonarscanner: 4.10.0
  • sonar-scanner-cli: 4.5.0.2216

Hi @aanogueira,

Welcome to SonarSource community! :wave:

Please take a look at our Community guide on generating reports for code coverage and unit tests for C# and VB.NET:

We support:

Import of coverage reports from VSTest, dotCover, OpenCover, Coverlet and NCover 3.
Import of unit test results from VSTest, NUnit and xUnit.

Also, please check out this guide on troubleshooting code coverage importing that I wrote: [ [Coverage] Troubleshooting guide for .NET code coverage import.

Hope this helps you,

Joe

1 Like

Hello @Joe,

Thank you for the welcoming as well as for the reply.
I’ve already checked the documentation, and I didn’t find any problem.

My problem was that, since I’m using coverlet I was missing coverlet.msbuild package reference in the .csproj file.

After some research, I found this issue were I saw this comment:.


Install coverlet 2.6.0 (latest version as of 02/04/19) using dotnet add package coverlet.msbuild


Right now, the test coverage is being imported as expected in my test dotnet-xunit example.

Thank you!
André Nogueira

1 Like

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