2

I am using this code to convert MSTest code covarage results to XML format , I added reference to Microsoft.VisualStudio.Coverage.Analysis.dll bu there is no class called CoverageInfoManager . I am using VS 2010.

 static void Main(string[] args)
        {
            String coveragepath = System.IO.Path.GetDirectoryName(args[0]);
            CoverageInfoManager.SymPath = coveragepath;
            CoverageInfoManager.ExePath = coveragepath;

            // Create a coverage info object from the file
            String coveragefile = System.IO.Path.GetFullPath(args[1]);
            CoverageInfo ci = CoverageInfoManager.CreateInfoFromFile(coveragefile);



            // Ask for the DataSet.  The parameter must be null
            CoverageDS data = ci.BuildDataSet(null);



            // Write to XML
            String coverageoutput = System.IO.Path.GetFullPath(args[2]);
            data.WriteXml(coverageoutput);

        }

If I use this code instead of above,

 CoverageInfo coverage = CoverageInfo.CreateFromFile(@"....\data.coverage");

it throws an error saying "Image file "...\bin\Debug\TestProject1.dll" could not be found"

Jayantha Lal Sirisena
  • 21,216
  • 11
  • 71
  • 92

3 Answers3

3

I had the same problem, I needed to convert the coverage file to coveragexml by command line.

You might want to use the CoverageInfo and CoverageDS objects as depicted on snip2code.

using (CoverageInfo info = CoverageInfo.CreateFromFile(coverageFileName, new string[] { dllFileName }, new string[] { }))
        {
            CoverageDS data = info.BuildDataSet();

            data.WriteXml(coverageXmlFileName);
        }

Link: How to programmatically convert the Visual Studio coverage file to coveragexml by command line tool in csharp

Dominique Terrs
  • 609
  • 8
  • 5
1

You can find a tool that does the conversion to clover and to html format

The code is located at github.

This tool also uses a xsl transformation to create the html report.

Mihai Iorga
  • 39,330
  • 16
  • 106
  • 107
Luke Syvil
  • 71
  • 3
0

You need to use a new method to access your coverage file. This will get you there I'm sure:

http://blogs.msdn.com/b/phuene/archive/2009/12/01/programmatic-coverage-analysis-in-visual-studio-2010.aspx

philiphobgen
  • 2,234
  • 17
  • 28