开发者

Convert MSTest code covarage results in to XML

开发者 https://www.devze.com 2023-03-11 05:41 出处:网络
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 us

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 = Cove开发者_如何学GorageInfo.CreateFromFile(@"....\data.coverage");

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


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


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消