Test file identified as new code?

I run the scanner with the option /d:sonar.dotnet.excludeTestProjects=true but after analysis I can see tests as part of new code, uncovered lines. The class is marked as a [TestFixture], methods are marked with [Test]. What am I missing?

We are using:

  • SonarQube Enterprise Edition Version 9.9 (build 65466)
  • ‘dotnet-sonarscanner’ (version ‘7.1.1’)
  • code is C#

If you go to the code tab, you will see which projects are recognized as test projects: these have no code coverage, instead —.

If SonarQube make mistakes in detecting if a project is a the test project (in general based on your settings in SonarQube), you can give the analyzer an indication in the csproj file:

<PropertyGroup>
    <SonarQubeTestProject>true</SonarQubeTestProject>
</PropertyGroup>
1 Like

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