locked
Using Visual Studio to do Code Coverage on gtest unit tests for native VS C++ RRS feed

  • Question

  • Friends,

    I have been looking at unit test code coverage tools for the last 2 weeks, evaluating them for our specific needs. The last one I would like to evaluate is Visual Studio's own code coverage for native C++ unit tests. In our solution, we have the following:

    • full Visual Studio 2013 development environment with large projects of  multi-100 k lines of code 
    • 900+ unit tests already written in GTEST (working and executing in the build process) and working in this environment
    • native C++ code (unmanaged)
    • a dozen projects in the solution or so

    What I am trying to do is figure out 

    • if I can use the Visual Studio code coverage Analysis tool to report results on my gtest unit tests
    • get code coverage results generated each time the unit tests or run (our unit tests are automatically run in a post-build step)

    I have looked around these forums, MSDN and other sites (like stackoverflow) and I can't find a good source of guidance to making this combination of tools work.  As I say, I have the solution, projects and unit tests running and working well, but to add code coverage I am not seeing how to do so using Microsoft's own Visual Studio code coverage.

    I have already evaluated a few other packages like Software Verify, Semantic Designs, OpenCPPCoverage and Bullseye.  I was hoping to try our Visual Studio's code coverage component since it is already part of our dev environment, but I can't seem to figure out how or if that will work.

    Any help?

    Thanks for any feedback, info you can give.


    • Edited by Kim Gentes Monday, March 2, 2015 9:46 PM readability
    Monday, March 2, 2015 9:46 PM

Answers

  • After searching more, I found that what I was missing was an adapter to run the tests in VS 2013. While my tests were executing as part of the build process, they weren't generating results in the Test Explorer because it wasn't being interfaced with Visual Studio's test explorer.  This can be done simply by installing an extension. The extension I found that works well for us is GoogleTest Runner, which is found in the extensions library here:

    I am leaving this question and answer here in case others have this same issue and need some help.

    • Marked as answer by Kim Gentes Monday, March 2, 2015 11:06 PM
    Monday, March 2, 2015 10:41 PM

All replies

  • After searching more, I found that what I was missing was an adapter to run the tests in VS 2013. While my tests were executing as part of the build process, they weren't generating results in the Test Explorer because it wasn't being interfaced with Visual Studio's test explorer.  This can be done simply by installing an extension. The extension I found that works well for us is GoogleTest Runner, which is found in the extensions library here:

    I am leaving this question and answer here in case others have this same issue and need some help.

    • Marked as answer by Kim Gentes Monday, March 2, 2015 11:06 PM
    Monday, March 2, 2015 10:41 PM
  • Glad to know that you have resolved this issue, Kim!

    Have a nice day,

    Jack


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, March 3, 2015 6:50 AM