使用VS2008 Team System对C++本地代码进行Code Coverage Report

2 篇文章 0 订阅

http://blogs.msdn.com/b/cellfish/archive/2008/11/16/native-c-code-coverage-reports-using-visual-studio-2008-team-system.aspx

The code coverage tool in Visual Studio 2008 Team System is quite easy to use from within the IDE unless you want code coverage for your native C++ code. In order to generate a code coverage report for native C++ you have to use the command line tools. This is how you do it:

  1. First of all your project must be compiled using the /PROFILE link option. If you bring up your project properties it can be found here:
    Configuration Properties -> Linker -> Advanced -> Profile
  2. The profiler tools can then be found in the following directory:
    C:/Program Files/Microsoft Visual Studio 9.0/Team Tools/Performance Tools
  3. You need to add some instrumentation code to your EXE or DLL file and that is done with this command:
    vsinstr.exe <YOUR_EXE_OR_DLL> /COVERAGE
    This will copy the original file to an ".orig"-file and create a new file with the original name that contains instrumentation code needed to gather coverage data.
  4. Now start the listener with this command:
    VSPerfMon.exe /COVERAGE /OUTPUT:<REPORT_FILE_NAME>
  5. Now run your EXE or some test suite that uses the file you want to calculate coverage for.
  6. The listener started in step four (4) will not stop by it self once your test suite is finished so you have to stop in manually using this command (from a second command prompt):
    VSPerfCmd.exe /SHUTDOWN
  7. When the listener has stopped you just drag-n-drop the created ".coverage"-file into Visual Studio and you can view the results.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值