将 MSTest 代码协方差结果转换为 XML

发布于 2024-11-14 08:26:33 字数 1078 浏览 4 评论 0原文

我使用此代码将 MSTest 代码协变结果转换为 XML 格式,我添加了对 Microsoft.VisualStudio.Coverage.Analysis.dll 的引用,但没有名为 CoverageInfoManager 的类。我正在使用 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);

        }

如果我使用此代码而不是上面的代码,

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

它会抛出一个错误,提示“无法找到图像文件“...\bin\Debug\TestProject1.dll””

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"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

汐鸠 2024-11-21 08:26:33

我遇到了同样的问题,我需要通过命令行将覆盖率文件转换为coveragexml。

您可能想要使用 CoverageInfo 和 CoverageDS 对象,如 snip2code 中所述。

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

            data.WriteXml(coverageXmlFileName);
        }

关联:
如何通过csharp中的命令行工具以编程方式将Visual Studio覆盖率文件转换为coveragexml

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

对你的占有欲 2024-11-21 08:26:33

您可以找到一个转换为 clover 和 html 格式的工具

代码位于 github

该工具还使用 xsl 转换来创建 html 报告。

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.

硬不硬你别怂 2024-11-21 08:26:33

您需要使用一种新方法来访问您的覆盖范围文件。
我确信这会让您到达那里:

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文