Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Coverage always at 0% on sonarqube even i added test unit

I created a test unit for a class and it passed well on my local, on sonarqube it is shown as 0% for Coverage, I found post advice to add coverlet.msbuild I added but still no news:

   <PackageReference Include="xunit" Version="2.4.1" />
   <PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
   <DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
   <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.0" />
   <PackageReference Include="coverlet.msbuild" Version="3.0.3">
     <PrivateAssets>all</PrivateAssets>
     <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> 
   </PackageReference>
 </ItemGroup>

Any idea?

like image 266
Sacamoto Avatar asked Sep 05 '25 03:09

Sacamoto


1 Answers

Try adding the following to your .csproj

<PropertyGroup>
  <DebugType>Full</DebugType>
</PropertyGroup>

<PackageReference Include="Microsoft.CodeCoverage" Version="16.9.4" />
like image 135
thepirat000 Avatar answered Sep 08 '25 14:09

thepirat000