4

The Microsoft code coverage tool (vsinstr.exe) generates a binary file to be read in Visual Studio. Can it also generate an XML file?

Wim Coenen
  • 66,094
  • 13
  • 157
  • 251
prosseek
  • 182,215
  • 215
  • 566
  • 871

3 Answers3

6

Minor correction: vsinstr.exe is the tool used to instrument a binary for code coverage (or profiling). VSPerfMon.exe is the code coverage monitor that actually writes the binary .coverage file to disk.

Inside the IDE, in the "Code Coverage Results" tool window, you can click "Export Results" to export the coverage data in an XML format:

Code coverage XML export.

VS2010 does not have a command-line utility to dump .coverage files to XML, however, you can use the code coverage API to do this yourself. See this blog post (and Peter's blog in general) and the CoverageDS.ExportXml function for doing so.

The coverage XML file has summary data that's similar to what you see in the VS UI. If you need more specific coverage details (e.g. per-block coverage information), you can use the code coverage API to get it.

Chris Schmich
  • 29,128
  • 5
  • 77
  • 94
2

As far as I know none Visual Studio version supports the coverage export feature on command line natively.

You can use the CoverageInfo and CoverageDS objects in a separated Visual Studio project to convert the file to xml format before generating the report.

You can refer to this answer: https://stackoverflow.com/a/20919775/2481351 based on this snippet on snip2code

Community
  • 1
  • 1
Jan Kohila
  • 169
  • 1
  • 5
2

You can also generate XML from command line using this:
http://blogs.msdn.com/b/ms_joc/archive/2005/04/08/406608.aspx

Uri Cohen
  • 3,488
  • 1
  • 29
  • 46