CppDepend Coverage Data

Coverage Data FAQ

Which coverage technology is supported by CppDepend?

CppDepend can import coverage data from:
  • Bullseye™ coverage files
  • Cobertura
  • Visual Studio Team System™

How to get XML Coverage Files from Visual Studio™ 2017, 2015, 2013, 2012 and 2010?

Visual Studio™ has 2 coverage files format.
  • A binary format where file extension is .coverage. This is the format you'll get from testing from Visual Studio or from TestDriven.NET. Alternatively you can also use the tool VSPerfMon.exe to get a .coverage file. For that you then need to instrument each assembly to cover with the tool VSInstr.exe used with the /Coverage option.
  • A XML format. (with file extension .coveragexml since VS 2010, and .xml for previous versions)
  • CppDepend only consumes the XML format. You can manually export XML coverage files from binary coverage files from Visual Studio with this option:

See the code snippet below, it takes 3 lines of code to programmatically transform a binary coverage file into a xml coverage file.
  • For that you'll need to reference from your project the assembly Microsoft.VisualStudio.Coverage.Analysis.dll:
    • A x86 version of this DLL can be found under C:\Program Files (x86)\Microsoft Visual Studio XX.0\Common7\IDE\PrivateAssemblies
    • A x64 version of this DLL can be found on x64 server where TFS is installed under C:\Program Files\Microsoft Team Foundation Server XX.0\Application Tier\TFSJobAgent\Plugins.
  • Both System.Data and System.Data.DataSetExtensions will have to be referenced as well.
  • And if you want your code to be independent from any VS or TFS install, you'll need to deploy as well Microsoft.VisualStudio.Coverage.Interop.dll that is used by Microsoft.VisualStudio.Coverage.Analysis.dll.
using Microsoft.VisualStudio.Coverage.Analysis;
   var pathInBinary = @"C:\Dir\File.coverage";
   var pathOutXml = @"C:\Dir\File.coveragexml";

   var coverageInfo = CoverageInfo.CreateFromFile(pathInBinary);
   var data = coverageInfo.BuildDataSet();

How to provide a list of coverage files to parse during each analysis run?

In VisualCppDepend menu: Project Properties > Analysis > Code Coverage > Settings

How to import coverage data into some analysis results

In VisualCppDepend menu: Coverage > Import Code Coverage Data
In VisualStudio menu: CppDepend > Coverage > Import Code Coverage Data