没有MSTest,我们能否在VS2012或VS2010中获得本机C ++代码覆盖? [英] Can we get native C++ code coverage in VS2012 or VS2010 without MSTest?

查看:81
本文介绍了没有MSTest,我们能否在VS2012或VS2010中获得本机C ++代码覆盖?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们想衡量我们在相当大的本地应用程序上运行的自动回归测试系统的代码覆盖率。这是一个使用我们应用程序内置脚本的复杂脚本测试系统。它具有成千上万的测试,不会被MSTest单元测试取代。

We would like to measure code coverage for our own automated regression test system run over a fairly large native app. This is a sophisticated, scripted test system using the inbuilt scripting of our app. It has thousands of tests and is not going to be replaced by MSTest unit tests.

虽然我们使用VS2012(Premium)作为IDE,但目前仍在使用它进行编译VS2010编译器和库。如果这是使代码覆盖范围继续发展的先决条件,那么这种更改可能会更快。

Whilst we're using VS2012 (Premium) as the IDE currently it is still compiled with the VS2010 compilers & libraries. That could change sooner if it was a prerequisite to getting code coverage going.

为此,我们可以进行单独的构建-检测不是问题。

We can do separate builds for this - instrumenting is not a problem.

我只是对阅读MS文档感到困惑,这似乎全都是假设您正在使用其内置的测试框架来运行单元测试。那时候我就不会在寻找真正真正涉及ALM本地支持的东西的时候了!

I'm just confused reading the MS documentation which seems to all start from an assumption you're running unit tests using their inbuilt test framework. That's when I'm not struggling to find stuff which actually talks about native support for ALM in the first place!

谢谢

推荐答案

Visual Studio 2012的代码覆盖工具与测试执行系统完全分开(完全披露:我写了它,但是我离开微软后继承它的团队删除了一些相当有用的工具)功能)。在VS 2012中对其进行了重新编写,以在加载到进程中时动态地检测本机(x86和x86-64)和托管代码(.NET和Silverlight),而不是修改磁盘上的可执行文件。

Visual Studio 2012's code coverage tool is entirely separate from the test execution system (full disclosure: I wrote it, but the team that inherited it after I left Microsoft removed some fairly useful functionality). It was rewritten from the ground up in VS 2012 to dynamically instrument native (x86 and x86-64) and managed code (.NET and Silverlight) when it loads into the process instead of modifying executables on disk.

您可以在%ProgramFiles%\Microsoft Visual Studio 11.0\团队工具\动态代码覆盖工具中找到CodeCoverage.exe。

You can find CodeCoverage.exe in "%ProgramFiles%\Microsoft Visual Studio 11.0\Team Tools\Dynamic Code Coverage Tools".

要收集数据:

CodeCoverage.exe collect /output:foo.coverage foo.exe foos_args

可以指定一个配置文件(该目录中的默认名称为CodeCoverage.config)来控制收集。

A configuration file (there's a default one in that directory called CodeCoverage.config) can be specified to control collection.

要分析覆盖率数据,可以在Visual Studio 2012中打开foo.coverage或使用覆盖率工具本身进行分析:

To analyze the coverage data, you can open foo.coverage in Visual Studio 2012 or use the coverage tool itself to do the analysis:

CodeCoverage.exe analyze /output:results.xml foo.coverage

注意:要进行检测,必须为您的模块发现.pdb文件。由于您使用的是2010版本,因此它们可能不适用于2012的DIA,因此您可能必须使用2012的工具集进行重建。如果没有在覆盖率分析中看到所需的模块,请将 / include_skipped_modules 传递给analyst命令;将会有一个原因属性,告诉您为什么跳过模块(排除,没有调试信息等)。

Note: for instrumentation to take place, .pdb files must be discovered for your modules. Since you are building with 2010, they may not work with 2012's DIA so you may have to rebuild with 2012's toolset. If you are not seeing the modules you expect in the coverage analysis, pass /include_skipped_modules to the analyze command; there will be a "reason" attribute telling you why the module was skipped (excluded, no debug information, etc.).

编辑:而且,与以前的Visual版本不同Studio,2012的覆盖率文件格式是完全独立的。在分析时不需要显示模块和.pdbs。

Also, unlike previous versions of Visual Studio, 2012's coverage file format is completely self-contained. The modules and .pdbs don't need to be present at analysis time.

这篇关于没有MSTest,我们能否在VS2012或VS2010中获得本机C ++代码覆盖?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆