Skip to content

[BUG] Inconsistent paths in cobertura reports #1723

Open
@rivnakm

Description

@rivnakm

Describe the bug

When producing coverage reports in cobertura format, the way the path is split between the <source> tag and the filename attribute on class tags is inconsistent across test projects. Sometimes the source tag is the path to the project directory, sometimes it's my home directory, and sometimes it's my root directory. Combining the two parts of the path is always correct, but the way they are split is inconsistent.

Other report formats don't split the path like cobertura, so the issue is not present there.

To Reproduce
Generate coverage reports for a solution with multiple test projects, using the cobertura format, with source link disabled.

Expected behavior
I'm not sure exactly what the expected root should be, I would expect it to be the test project directory, with class files being relative to that. Overall it should be consistent across projects.

Actual behavior
Coverage source directories are inconsistent between multiple test projects within the same solution.

  <sources>
    <source>/home/michael/Code/anna/Anna.Index/</source>
  </sources>
  <packages>
    <package name="Anna.Index" line-rate="0.9764" branch-rate="1" complexity="39">
      <classes>
        <class name="Anna.Index.PackageIndex" filename="PackageIndex.cs" line-rate="1" branch-rate="1" complexity="1">
  <sources>
    <source>/</source>
  </sources>
  <packages>
    <package name="Anna.Storage" line-rate="0.9823999999999999" branch-rate="1" complexity="16">
      <classes>
        <class name="Anna.Storage.PackageStorage" filename="home/michael/Code/anna/Anna.Storage/PackageStorage.cs" line-rate="0.9761" branch-rate="1" complexity="12">

Configuration (please complete the following information):
Please provide more information on your .NET configuration:
* Which coverlet package and version was used?
* Which version of .NET is the code running on?
* What OS and version, and what distro if applicable?
* What is the architecture (x64, x86, ARM, ARM64)?
* Do you know whether it is specific to that configuration?

Coverlet: v6.0.2
.NET 8.0 (8.0.111)
OS: Fedora Linux 41 x64

The same behavior is observed in my ubuntu github actions runners.

Additional context
Add any other context about the problem here.

❗ Please also read Known Issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already existsquestionThis issue is a question

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions