Skip to content

Support OpenCover output format #98

Open

Description

@josundt

OpenCover is the best format when integrating with SonarCloud/SonarQube.
Sonar supports MS VS .coverage (binary) and VS coverage xml formats as well, but these formats give unexpected line coverage metrics (see #97).

Until OpenCover is a supported output format, coverlet remains the preferred option for us,

Activity

  1. josundt commented on Feb 15, 2024

    @josundt
    Author

    I'll give you some more details about my findings:

    1. In the Azure DevOps pipeline after switching from Cobertura (using Publish Code Coverage Results v1 task) to MS Coverage XML (using Publish Code Coverage Results v2 task), the reported "lines covered" remained exactly the same 👍

    2. With SonarCloud after switching from OpenCover to MS Coverage XML, the "lines covered" count dropped by 50%.

    I looks like the main problem may be SonarCloud rather than the XML file written by your tool.
    Still the only currently acceptable solution for us is to revert back to OpenCover and coverlet.

    If your tooling had supported the OpenCover output format (and ideally also an improved way specifying output file or folder paths when using multiple files in different formats), we would have started to use Microsoft.CodeCoverage instead.

  2. SeMuell commented on Mar 7, 2024

    @SeMuell

    After doing some analysis I totally agree that supporting OpenCover would be very beneficial. We have to stick to SonarQube and the analysis takes around 3-5 times as long with the VS coverage xml format than with OpenCover produced by coverlet.

    Unfortunately, all performance benefits we gain using the Microsoft.CodeCoverage in comparison to coverlet is taken by not supporting OpenCover.

    Until OpenCover is a supported output format, coverlet remains the preferred option for us as well.

  3. martin-strecker-sonarsource commented on May 29, 2024

    @martin-strecker-sonarsource

    Hello josundt

    The issue you are seeing might be related to SonarSource/sonar-dotnet#3191. Can you provide us a reproducer? We are looking for code patterns that are not properly imported by our coverage importer. One example is methods using yield return, but there might be more such patterns.

  4. josundt commented on Nov 28, 2025

    @josundt
    Author

    I just tested - as part of the .NET 10 migration of our solutions - to also migrate to the new Microsoft.Testing.Platform, following the steps in this article.

    I updated global.json, added the required properties to the unit test csproj files, added the package references for Microsoft.Testing.Extensions.TrxReport and Microsoft.Testing.Extensions.CodeCoverage to support generation of the desired test execution and coverage reports, and started updating the dotnet test arguments.

    Everything seemed to work perfect and I was able to complete 99% of the migration to Microsoft.Testing.Platform, except one little thing:

    • I'm not able to generate OpenCover coverage reports required for SonarCloud.

    I suddenly had this deja vu sensation, slowly realizing that I'm being haunted by a ghost from the past, and found my way back to this issue that I reported almost 2 years ago.
    I realize that the Microsoft.Tesing.Platform uses components from this repository as well, and OpenCover support has still not been prioritized.

    We need to integrate our build pipelines with SonarCloud, so this practically means that I have to revert back from Microsoft.Test.Platform to VSTest - which I assume will soon become the "legacy" and later the "retired" testing platform.

    Can you please consider supporting OpenCover in Microsoft.Testing.Extensions.CodeCoverage?
    I should not be a very time consuming task?

  5. fhnaseer commented on Dec 1, 2025

    @fhnaseer
    Member

    Unfortunately, it is still not prioritized from our side. Scope of this is very big as it doesn't involve only adding support of creating OpenCover report. But it also adding support in Visual Studio, Visual Studio Code. And merging with different report formats.

    I can suggest the following workaround for your scenario

    1. Create a cobertura report using Microsoft.Testing.Platform using --coverage-output-format cobertura https://github.com/microsoft/codecoverage/blob/main/samples/Algorithms/scenarios/scenario01/README.md
    2. Use reportgenerator to convert this report to OpenCover https://reportgenerator.io/usage
    3. Use the generated report in SonarCloud.
  6. N-Olbert commented on Jan 20, 2026

    @N-Olbert

    Use reportgenerator to convert this report to OpenCover

    Please note that the conversation to OpenCover requires a pro-license of reportgenerator.
    Therefore, this is not a "real" workaround that is applicable for everyone.

    However, if OpenCover is just required for SonarQube, one may use --coverage-output-format xml as mentioned above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions