[英]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.