question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

dotCover-Reports and TFS

See original GitHub issue

I’m trying to get code coverage working for our TFS-based CI build. As coverage tool I’m using JetBrains’ dotCover, which appears to work fine. Now, I want to publish that coverage on the TFS. MS provides the build task “Publish Code Coverage Report” which supports Cobertura and JaCoCo coverage files.

Thus, I would like to use the ReportGenerator task to convert the given coverage file into Cobertura format - how do I do this? 😃

I have configured the ReportGenerator task as follows:

  • Reports: Path to coverage file as produced by dotCover
  • Target directory: Path to some directory from where I want to pick up the Cobertura coverage file by the mentioned “Publish Code Coverage” task
  • Report types: Cobertura

The output of the build server is as follows:

==============================================================================
Task         : ReportGenerator
Description  : ReportGenerator converts XML reports generated by OpenCover, PartCover, dotCover, Visual Studio, NCover, Cobertura or JaCoCo into human readable reports in various formats.
Version      : 1.0.3
Author       : Palmmedia
Help         : [More Information](https://github.com/danielpalme/ReportGenerator)
==============================================================================
"C:\Program Files\dotnet\dotnet.exe" C:\Agents\CX-BUILD01-Agent02\_work\_tasks\reportgenerator_be803a55-9253-4895-a525-be570d86f161\1.0.3\tools\netcoreapp2.0\ReportGenerator.dll -reports:C:\DotCoverResults\CoverageReport.xml -targetdir:C:\ReportGeneratorResults -reporttypes:Cobertura -sourcedirs: -historydir: -plugins: -assemblyfilters:+* -classfilters:+* -filefilters:+* -verbosity:Verbose -tag:20181112.7_#(build.buildid)
Loading report 'C:\DotCoverResults\CoverageReport.xml' 1/1
Coverage report parsing took 1,0 seconds
Initializing report builders for report types: Cobertura
Analyzing 0 classes
 Creating summary
Report generation took 1,1 seconds

For the sake of simplicity, I then downloaded the NuGet package and tried to locally generate a Cobertura coverage file, again with no luck. Here’s my command and output:

PS C:\Users\foo\Desktop\reportgenerator.4.0.3\tools\net47> .\ReportGenerator.exe -reports:CoverageReport.xml -reporttypes:Cobertura -targetdir:the_report
Loading report 'C:\Users\foo\Desktop\reportgenerator.4.0.3\tools\net47\CoverageReport.xml' 1/1
Coverage report parsing took 0,4 seconds
Initializing report builders for report types: Cobertura
Analyzing 0 classes
 Creating summary
Report generation took 0,4 seconds

After execution, the directory the_report indeed contains a file Cobertura.xml, but it’s pretty much empty:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-04.dtd">
<coverage line-rate="1" branch-rate="1" lines-covered="0" lines-valid="0" branches-covered="0" branches-valid="0" complexity="NaN" version="0" timestamp="1542036076">
  <sources />
  <packages />
</coverage>

For the sake of completeness, here’s the beginning of the dotCover coverage file I’d like to convert:

<?xml version="1.0" encoding="utf-8"?>
<Root CoveredStatements="5156" TotalStatements="321286" CoveragePercent="2" ReportType="Xml" DotCoverVersion="2018.2.3">
  <Assembly Name="Archiv" CoveredStatements="0" TotalStatements="9619" CoveragePercent="0">
    <Namespace Name="Archiv" CoveredStatements="0" TotalStatements="8497" CoveragePercent="0">
      <Type Name="ArchivDB" CoveredStatements="0" TotalStatements="123" CoveragePercent="0">
        <Constructor Name="ArchivDB()" CoveredStatements="0" TotalStatements="10" CoveragePercent="0" />
        <Constructor Name="ArchivDB()" CoveredStatements="0" TotalStatements="21" CoveragePercent="0" />
        <AutoProperty Name="Ablagetypen:IDBTableG&lt;int,DateiablageTyp&gt;" CoveredStatements="0" TotalStatements="1" CoveragePercent="0">
          <PropertyGetter CoveredStatements="0" TotalStatements="1" CoveragePercent="0" />
        </AutoProperty>

Am I doing anything wrong? I had seen this comment, but I’m not sure what it means, since there does not seem to be a ReportType argument (only reporttypes), plus, I do not see DetailedXML mentioned in the help output, so my guess is that this is outdated…

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:23 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
DLMorrellcommented, Jun 3, 2019

That worked, thanks for your help! You’re awesome and I hope you have a good day!

1reaction
csoltenborncommented, Mar 14, 2019

I think that I’m doing this already! Here’s a screenshot of an excerpt of our TFS build definition:

TFS build

Details of the ReportGenerator task configuration (the history directory points to some network drive accessible by all build agents):

Config ReportGenerator-Task

Finally, the Publish code coverage results task:

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Zero code Coverage using dotCover + TFS Build
When the build is successfully completed , the Sonar dashboard stills shows 0 coverage although in the logs I am able to see...
Read more >
Work with Coverage Results | dotCover Documentation
Unit Test Coverage window (available only in Visual Studio) - this tool window displays coverage tree and synchronizes it with unit tests from ......
Read more >
Coverage Analysis from the Command Line - dotCover
Generate coverage reports in different formats. Use report command to generate reports in desired formats from coverage snapshots. And more.
Read more >
Publishing dotCover CLI code coverage reports to Azure ...
Code coverage is one of the metrics that determine the quality of the code. It measures, in percentage values, how well unit tests...
Read more >
dotCover for code coverage in Visual Studio - YouTube
In this video, Maarten provides a summary of JetBrains dotCover, a unit test runner and code coverage tool for Visual Studio.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found