使用Visual Studio 2013 Professional针对本机C ++进行代码覆盖率报告 [英] Code Coverage Reporting with Visual Studio 2013 Professional for native C++

查看:132
本文介绍了使用Visual Studio 2013 Professional针对本机C ++进行代码覆盖率报告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用带有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:

  1. 构建要使用/PROFILE链接器开关
  2. 进行测试的代码
  3. 运行vsinstr /coverage <binaryName>来检测代码;确保您位于VS 2013命令提示符下
  4. 运行start vsperfmon -coverage -output:results以运行分析器
  5. 运行单元测试
  6. 通过运行vsperfcmd -shutdown
  7. 停止事件探查器
  1. Build the code to test with with /PROFILE linker switch
  2. Run vsinstr /coverage <binaryName> to instrument the code; make sure that you are inside VS 2013 command prompt
  3. Run start vsperfmon -coverage -output:results to run the profiler
  4. Run your unit tests
  5. 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( 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 ++进行代码覆盖率报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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