简体   繁体   English

Visual Studio 2012 C ++代码覆盖率合并可执行文件

[英]Visual Studio 2012 C++ code coverage merge executables

My c++ unit tests use gtest framework so every test is a separate executable. 我的c ++单元测试使用gtest框架,因此每个测试都是一个单独的可执行文件。 I'm running the CodeCoverage.exe tool to get the raw coverage data of each executable run. 我正在运行CodeCoverage.exe工具来获取每个可执行文件运行的原始覆盖数据。 When I open the results in Visual Studio, each executable run appears in a separate branch and the results can't be merged together. 当我在Visual Studio中打开结果时,每个可执行文件运行都出现在一个单独的分支中,结果无法合并在一起。
Is there any way to make this work? 有没有办法让这项工作?

One thing I've tried is to specify /session:uniq in the command line for both runs but that didn't have any effect. 我尝试过的一件事是在命令行中为两次运行指定/session:uniq ,但这没有任何效果。

Does it help you to capture via vsperfcmd.exe? 它是否可以帮助您通过vsperfcmd.exe捕获?

  1. Build your gtest with /profile flag specified to the linker 使用为链接器指定的/profile标志构建gtest
  2. Instrument your gtest exe with Visual Studio coverage instrumentation 使用Visual Studio coverage工具检测gtest exe
    • vsinstr.exe gtest.exe /COVERAGE
  3. Launch the code coverage capture tool 启动代码覆盖率捕获工具
    • vsperfmon.exe /COVERAGE /OUTPUT:gtest.coverage
  4. Run the gtest 运行gtest
  5. Stop the capture tool 停止捕获工具
    • vsperfcmd.exe -shutdown
  6. Launch the output file (gtest.coverage) to see the output in Visual Studio 启动输出文件(gtest.coverage)以查看Visual Studio中的输出

OK, this should have been a comment, but I don't have the permissions yet. 好吧,这应该是评论,但我还没有权限。 You can run all your unit tests with the macro: RUN_ALL_TESTS(); 您可以使用宏运行所有单元测试:RUN_ALL_TESTS();

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM