Improving Software Quality with Code Coverage in CppDepend
- Which coverage technology is supported by CppDepend?
- How to get XML Coverage Files from Microsoft Visual Studio�?
- How to get XML Coverage Files from CTC++?
- How to provide a list of coverage files to parse during each analysis run?
- How to import coverage data into some analysis results?
Which coverage technology is supported by CppDepend?
CppDepend can import coverage data from:- Bullseye� coverage files
- Cobertura
- Visual Studio Team System�
- CTC++
How to get XML Coverage Files from Microsoft Visual Studio�?
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. Alternatively you can also use the tool VSPerfMon.exe to get a .coverage file. For that you then need to instrument each projet 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.
...
var pathInBinary = @"C:\Dir\File.coverage";
var pathOutXml = @"C:\Dir\File.coveragexml";
var coverageInfo = CoverageInfo.CreateFromFile(pathInBinary);
var data = coverageInfo.BuildDataSet();
data.WriteXml(pathOutXml);
How to get XML Coverage Files from CTC++?
You can use the Ctc2cob tool which converts Testwell CTC++ reports into Cobertura-like XML reports.
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
or
In VisualStudio menu: CppDepend > Coverage > Import Code Coverage Data