首页 > 编程语言 > 详细

代码覆盖率检测C++

时间:2020-03-26 17:30:33      阅读:93      评论:0      收藏: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.

代码覆盖率检测C++

原文:https://www.cnblogs.com/trxdy/p/12575702.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!