Skip to content

Difference in cobertura report between coverlet 2.4.0 and 2.5.0 #295

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rwasala opened this issue Jan 15, 2019 · 4 comments · Fixed by #614
Closed

Difference in cobertura report between coverlet 2.4.0 and 2.5.0 #295

rwasala opened this issue Jan 15, 2019 · 4 comments · Fixed by #614

Comments

@rwasala
Copy link

rwasala commented Jan 15, 2019

Issue description

When I run tests using command:

dotnet test /p:CopyLocalLockFileAssemblies=true /p:Exclude=\"[System.*]*\" /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura

in my sample project https://github.com/rwasala/CodeCoverage I get different output in reports.
For version 2.4.0 it looks like:

<?xml version="1.0" encoding="UTF-8"?>
<coverage line-rate="1" branch-rate="1" version="1.9" timestamp="1547558846" lines-covered="26" lines-valid="26" branches-covered="4" branches-valid="4">
  <sources>
    <source>/var/lib/jenkins/workspace/Build_CodeCoverage_master/SampleLib/</source>
  </sources>
  <packages>
    <package name="SampleLib" line-rate="1" branch-rate="1" complexity="10">
      <classes>
        <class name="SampleLib.Author" filename="Author.cs" line-rate="1" branch-rate="0" complexity="3">
          <methods>
            <method name="get_Id" signature="()" line-rate="1" branch-rate="0">

For version 2.5.0 it looks like:

<?xml version="1.0" encoding="UTF-8"?>
<coverage line-rate="1" branch-rate="1" version="1.9" timestamp="1547558132" lines-covered="26" lines-valid="26" branches-covered="4" branches-valid="4">
  <sources/>
  <packages>
    <package name="SampleLib" line-rate="1" branch-rate="1" complexity="10">
      <classes>
        <class name="SampleLib.Author" filename="/var/lib/jenkins/workspace/Build_CodeCoverage_master/SampleLib/Author.cs" line-rate="1" branch-rate="1" complexity="3">
          <methods>
            <method name="get_Id" signature="()" line-rate="1" branch-rate="1">

Basically the difference is that in version 2.5.0 node source is empty which causes problems with cobertura Jenkins plugin - it is not showing the source code with marked what is covered and what is not.

Is it possible to make report from coverlet.msbuild in version 2.5.0 the same like in 2.4.0?

@tonerdo tonerdo pinned this issue Mar 3, 2019
@tonerdo
Copy link
Collaborator

tonerdo commented Mar 3, 2019

This happens because I switched to using absolute paths. #356 re-includes the source element

@tonerdo tonerdo unpinned this issue Mar 3, 2019
@jpaskhay
Copy link

We're using 2.6.0 and it appears there are still issues with this. Jenkins can't render the source and shows the Source code is unavailable.... message. The filename it attempts to render is var/lib/jenkins/workspace/.... (note missing leading slash).

It appears the cobertura Jenkins plugin strips the leading slash character and expects a relative path: https://github.com/jenkinsci/cobertura-plugin/blob/master/src/main/java/hudson/plugins/cobertura/CoberturaCoverageParser.java#L172-L176

A hacky fix (short of refactoring the SourceLink related changes) could be adding the slash character to the <source> element that was added back (i.e. <source>/</source>).

@nlowe
Copy link

nlowe commented May 6, 2019

We're seeing this as well. I reverted back to coverlet.msbuild 2.4.0 as a workaround.

@vikasillumina
Copy link

vikasillumina commented May 9, 2019

@tonerdo I noticed this same issue too with 2.6.0

[Cobertura] Publishing Cobertura coverage report...

[Cobertura] No coverage results were found using the pattern '**/TestResults/coverage.*.xml' relative to '/home/ec2-user/workspace/'.  Did you enter a pattern relative to the correct directory?  Did you generate the XML report(s) for Cobertura?

This is our jenkin pipeline step that is failing right now with 2.6.0:

step([$class             : 'CoberturaPublisher',
                      autoUpdateHealth   : false,
                      autoUpdateStability: false,
                      coberturaReportFile: '**/TestResults/coverage.*.xml',
                      failUnhealthy      : false,
                      failUnstable       : false,
                      maxNumberOfBuilds  : 0,
                      onlyStable         : false,
                      sourceEncoding     : 'ASCII',
                      zoomCoverageChart  : false])

Same reporter works fine with 2.3.1 and we have been using it since last year.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants