简体   繁体   English

如何在Visual Studio 2010中的C ++ googletest项目中设置代码覆盖率

[英]How do I set up code coverage in C++ googletest project in Visual Studio 2010

I have a C++ googletest project building in Visual Studio 2010 professional. 我在Visual Studio 2010专业版中有一个C ++ googletest项目。 This builds a console application which generates XML test result output. 这构建了一个生成XML测试结果输出的控制台应用程序。 How can I set it up to get code coverage information? 如何设置它以获取代码覆盖率信息?

I have tried instructions here to instrument the code but viewing the Code Coverage results seems to require Visual Studio Ultimate. 我已经尝试过这里的指令来检测代码,但查看代码覆盖率结果似乎需要Visual Studio Ultimate。 Is there any converter for the .coverage files Visual Studio generates? Visual Studio生成的.coverage文件是否有转换器?

Bonus points for portable/free/open-source solutions! 便携/免费/开源解决方案的奖励积分!

You can try OpenCppCoverage: http://opencppcoverage.codeplex.com . 您可以尝试OpenCppCoverage: http ://opencppcoverage.codeplex.com。

OpenCppCoverage is a code coverage tools for C++ under Windows. OpenCppCoverage是Windows下C ++的代码覆盖工具。 It is open-source and works well with google test / Visual Studio C++. 它是开源的,适用于google test / Visual Studio C ++。

Disclaimer: I am the author of this tool. 免责声明:我是这个工具的作者。

Hope that help. 希望有所帮助。

Edit to follow brasofilo advice: 编辑以遵循brasofilo建议:

To be more precise about your question, OpenCppCoverage should work with Visual Studio C++ 2010 professional. 为了更准确地解决您的问题,OpenCppCoverage应该与Visual Studio C ++ 2010专业人员一起使用。 The only requirement is to support native Pdb files ( http://msdn.microsoft.com/en-us/library/yd4f8bd1%28vs.71%29.aspx ). 唯一的要求是支持本机 Pdb文件( http://msdn.microsoft.com/en-us/library/yd4f8bd1%28vs.71%29.aspx )。

It is open source and free and you can find sources here: https://opencppcoverage.codeplex.com/SourceControl/latest . 它是开源的,免费的,你可以在这里找到资源: https//opencppcoverage.codeplex.com/SourceControl/latest

What do you mean by portable? 便携式是什么意思?

Hope that help. 希望有所帮助。

I think you can use the VSTEST.Consol.exe for this purpose http://msdn.microsoft.com/en-us/library/vstudio/jj155796.aspx . 我认为您可以使用VSTEST.Consol.exe来实现此目的http://msdn.microsoft.com/en-us/library/vstudio/jj155796.aspx According to documentation, it would run tests written against any test framework. 根据文档,它将运行针对任何测试框架编写的测试。 You may enable the /Enablecodecoverage option, which Enables data diagnostic adapter CodeCoverage in the test run. 您可以启用/Enablecodecoverage选项,该选项Enables data diagnostic adapter CodeCoverage in the test run.

More information may be found here: http://blogs.msdn.com/b/bhuvaneshwari/archive/2012/06/16/vstest-console-exe-commandline-test-runner.aspx 可在此处找到更多信息: http//blogs.msdn.com/b/bhuvaneshwari/archive/2012/06/16/vstest-console-exe-commandline-test-runner.aspx

There is also an open source code coverage tool called ggcov: http://ggcov.sourceforge.net/index.html 还有一个名为ggcov的开源代码覆盖工具: http ://ggcov.sourceforge.net/index.html

Hope that these helps. 希望这些有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何设置Vim以使用Visual Studio 2010的C ++编译器进行编译? - How do I set up Vim to compile using Visual Studio 2010's C++ compiler? 如何使Visual Studio 2015 C ++项目与Visual Studio 2010兼容? - How do I make a Visual Studio 2015 C++ project compatible with Visual Studio 2010? Visual Studio 2010本机C ++代码覆盖率着色不起作用 - Visual Studio 2010 Native C++ Code Coverage Coloring Not Working 如何在大型 C++ 项目的可视化代码中设置调试 - How do I set up debugging in visual code for a large c++ project 如何设置Visual Studio 2010项目以为Slickedit 17构建64位扩展名dll? - How do I set up a Visual Studio 2010 project for building a 64 bit extension dll for Slickedit 17? 如何在Visual Studio 2010中查看C ++函数的已编译机器代码或字节代码? - How do I view the compiled machine code or byte code for a C++ function in Visual Studio 2010? Visual Studio C ++项目管理。 如何处理项目中的非代码文件? - Visual Studio C++ project management. How do I handle non-code files in a project? 现有代码中的Visual Studio 2010新C ++项目 - Visual Studio 2010 new C++ project from existing code 如何在GitHub上正确设置Visual Studio C ++项目? - How do I properly set up Visual Studio C++ projects on GitHub? 如何将项目从Visual C ++ 6.0转换为Visual Studio Express 2010? - How can I convert a Project from Visual C++ 6.0 to Visual Studio Express 2010?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM