Feature Request: Import Visual Studio coverage in Cobertura format

I use Sonarqube Version 9.5 and am investigating, if we can use the code coverage provided by Microsoft to determine the coverage of our .NET projects. Right now we are using a mix of coverlet (with opencover format output) and Microsoft’s solution, but because configuration and exclusion lists for the Microsoft solution are more up to date, it would be beneficial to consolidate to that one.

When comparing both metrics I noticed one downside of the Microsoft solution though: Branch coverage is reported (left coverlet; right Microsoft):

I assume this is because the Microsoft Solution does not output the branch information in its XML format [1] [2] [3].

The Microsoft solution allows to output the coverage in Cobertura format though, which - as far as I understand it - will contain the coverage information that Sonar usually displays. Example:

<methods>
  <method line-rate="1" branch-rate="0.5" complexity="2" name=".ctor"
    signature="(Microsoft.AspNetCore.Http.IHttpContextAccessor)">
    <lines>
      <line number="12" hits="1" branch="False" />
      <line number="13" hits="1" branch="False" />
      <line number="14" hits="1" branch="True" condition-coverage="50% (1/2)">
        <conditions>
          <condition number="0" type="jump" coverage="50%" />
        </conditions>
      </line>
      <line number="15" hits="1" branch="False" />
    </lines>
  </method>

Therefore I am opening this feature request to support Cobertura as an import option for C# coverage.

1 Like

Typo, which i can’t edit anymore :thinking:

Branch coverage is not reported (left coverlet; right Microsoft):

1 Like

Hi Justus

Thanks for sharing this insight. We are considering supporting Cobertura format, I can’t give you an indication of when this will happen but I’ll try and update this thread when it does.

Tom

1 Like