使用VS2008 Team System对C++本地代码进行Code Coverage Report
2014-09-03 09:56
621 查看
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:
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
The profiler tools can then be found in the following directory:
C:/Program Files/Microsoft Visual Studio 9.0/Team Tools/Performance Tools
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.
Now start the listener with this command:
VSPerfMon.exe /COVERAGE /OUTPUT:<REPORT_FILE_NAME>
Now run your EXE or some test suite that uses the file you want to calculate coverage for.
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
When the listener has stopped you just drag-n-drop the created ".coverage"-file into Visual Studio and you can view the results.
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:
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
The profiler tools can then be found in the following directory:
C:/Program Files/Microsoft Visual Studio 9.0/Team Tools/Performance Tools
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.
Now start the listener with this command:
VSPerfMon.exe /COVERAGE /OUTPUT:<REPORT_FILE_NAME>
Now run your EXE or some test suite that uses the file you want to calculate coverage for.
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
When the listener has stopped you just drag-n-drop the created ".coverage"-file into Visual Studio and you can view the results.
相关文章推荐
- 使用 Ratinal Purecoverage 进行 C++ 代码覆盖率分析
- 使用 Ratinal Purecoverage 进行 C++ 代码覆盖率分析
- 代码覆盖测试-Code Coverage Testing with EclEmma-使用篇
- 在C/C++代码中使用SSE等指令集的指令(5)SSE进行加法运算简单的性能测试
- 使用VAssistX为VS2008 c++代码添加函数头注释
- 使用JNI进行Java与C/C++语言混合编程(1)--在Java中调用C/C++本地库
- 使用 Visual Studio 2005 Team System 进行单元测试并生成用于 Unit Test Framework 的源代码
- 使用JNI进行混合编程:在Java中调用C/C++本地库
- 使用 Visual Studio 2005 Team System 进行单元测试并生成用于 Unit Test Framework 的源代码
- 在C/C++代码中使用SSE等指令集的指令(5)SSE进行加法运算简单的性能测试
- C/C++代码静态检查工具PC-lint在VS2008开发环境中的安装配置和使用
- 使用 Visual Studio 2005 Team System 进行单元测试并生成用于 Unit Test Framework 的源代码 (实例)
- 使用 Visual Studio 2005 Team System 进行单元测试并生成用于 Unit Test Framework 的源代码(详解)
- 使用VAssistX为VS2008 c++代码添加函数头注释 .
- 使用JNI进行混合编程:在C/C++中调用Java代码
- 使用 Visual Studio 2005 Team System 进行单元测试并生成用于 Unit Test Framework 的源代码 (实例) (轉載)
- 使用 Visual Studio 2005 Team System 进行单元测试并生成用于 Unit Test Framework 的源代码
- 使用JNI进行Java与C/C++语言混合编程(1)--在Java中调用C/C++本地库
- C/C++代码静态检查工具PC-lint在VS2008开发环境中的安装配置和使用
- 使用 Visual Studio 2005 Team System 进行单元测试并生成用于 Unit Test Framework 的源代码