Loss of coverage in test project after SonarQube update

  • SonarQube Community Build,
  • how is SonarQube deployed: zip

Hello everyone. After upgrading our SonarQube instance (from 8.2 to 24.12), we noticed a significant drop in code coverage in our .NET projects, as shown in the images below.

Scenario before the update (SonarQube 8.2):
Our project *TesteUnitario was recognized normally in coverage.

The coverage was computed and displayed correctly: 94.2% for the test project.

All test files were visible and counted in the Code tab.

(I know that the right thing is that the test project doesn’t count towards the coverage percentage, but I currently need it to count until we resolve this for all projects.)

I tried to include filters using the -filter argument with +[]
I also tried to put Key: sonar.test.inclusions in the settings with the pattern **/Test.cs

but none of the options worked

Does anyone have any tips or suggestions for a workaround? Because the idea is to let these tests count as coverage for the next 2 months at most.

I’m not looking to make this permanent — just a workaround or setting to temporarily maintain
the test project’s visibility in the Code tab and coverage metrics.


Hi,

First, congratulations on your upgrade. That’s a big jump!

Second, I’m a little confused. :sweat_smile:

The complaint is that test files are now correctly recognized as not being code? And that’s not what you want?

If so, this might help.

 
Ann

1 Like

is exactly what I need, putting the:

  <PropertyGroup>
	<SonarQubeTestProject>false</SonarQubeTestProject>
  </PropertyGroup>

In the Unit Testing csproj, the new version of Sonar is now included % coverage again. I know this generates an incorrect metric, but for now it will be necessary.

Eternally grateful for the help, it saved me.

1 Like