将 MSTest 代码协方差结果转换为 XML
我使用此代码将 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我遇到了同样的问题,我需要通过命令行将覆盖率文件转换为coveragexml。
您可能想要使用 CoverageInfo 和 CoverageDS 对象,如 snip2code 中所述。
关联:
如何通过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.
Link:
How to programmatically convert the Visual Studio coverage file to coveragexml by command line tool in csharp
您可以找到一个转换为 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.
您需要使用一种新方法来访问您的覆盖范围文件。
我确信这会让您到达那里:
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