问题描述
使用带有Visual Studio 2013 Professional的C ++单元测试框架,可以编写单元测试并在IDE中运行它们,但是显然,为了生成任何覆盖率报告,人们需要拥有Visual的Premium或Ultimate版本工作室.
Using the C++ unit testing framework with Visual Studio 2013 Professional, one can write unit tests and run them from within the IDE, but in order to generate any coverage reports, apparently, one needs to have the Premium or Ultimate edition of Visual Studio.
是否可以使用Professional版本获得代码覆盖率报告,最好不安装任何第三方工具? IDE?
请注意,可以使用命令行工具来生成coverage数据,但是我找不到找到结果的方法.为参考起见,以下是用于生成覆盖率统计信息的命令行的步骤:
Please note that it's possible to generate the coverage data by using command line tools, but I am unable to find a way to look at the results. For the sake of reference, here are the steps for command line generation of the coverage statistics:
- 构建要使用
/PROFILE
链接器开关 进行测试的代码 - 运行
vsinstr /coverage <binaryName>
来检测代码;确保您位于VS 2013命令提示符下 - 运行
start vsperfmon -coverage -output:results
以运行分析器 - 运行单元测试
- 通过运行
vsperfcmd -shutdown
停止事件探查器
- Build the code to test with with
/PROFILE
linker switch - Run
vsinstr /coverage <binaryName>
to instrument the code; make sure that you are inside VS 2013 command prompt - Run
start vsperfmon -coverage -output:results
to run the profiler - Run your unit tests
- Stop the profiler by running
vsperfcmd -shutdown
上面提供的是results.coverage文件,据我所知,如果没有Premium或Ultimate版本,则无法查看该文件.
The above will give you a results.coverage file, with no way to view it without the Premium or Ultimate editions as far as I know.
推荐答案
使用VS2013 Professional,如果您想在没有第三方工具的情况下进行操作,则很不走运.Requirements: Visual Studio Ultimate, Visual Studio Premium
( http://msdn.microsoft.com/en-us/library/dd537628.aspx ).据我了解,您已经设法生成* .coverage文件,并且在打开文件时遇到了问题.视觉范围( https://github.com/jsargiot/visual-coverage )工具可以帮助您有了它,它非常易于使用,并且是开源的.如果您想找到更多替代方法,请参见另一个SO线程:查看代码Visual Studio之外的覆盖范围结果.这些工具适用于C#覆盖率文件,但据我了解应该没有什么区别.
With VS2013 Professional you are out of luck if you want to do it without third party tools Requirements: Visual Studio Ultimate, Visual Studio Premium
(http://msdn.microsoft.com/en-us/library/dd537628.aspx). From what I understand you already managed to generate your *.coverage file and you are having problems opening it. Visual Coverage (https://github.com/jsargiot/visual-coverage) tool can help you with that, its very simple to use and it is opensource. If you would like to find more alternatives, see another SO thread: Viewing Code Coverage Results outside of Visual studio. The tools are meant for C# coverage files but from what I understand there should not be any difference.
这篇关于使用Visual Studio 2013 Professional针对本机C ++进行代码覆盖率报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!