How can I get code coverage using gtest on Windows?
Code coverage in C++ can not be handled by the testing framework solely, because a coverage analysis tool has to know the whole extent of the code (wich the testing framework has not) and it has to instrument the code under test somehow to monitor wich parts of the code get executed.
I had the same desire like you once, wanting to measure my test coverage in MSVC. This is what I learned:
MSVC ships with some command line tools for these instrumentations, googling a bit will get you one or two msdn blog posts about how to use them. Frankly, its not very convenient and easy to use. If you look for third party tools, you will probably not find any free ones. Any tools I found at all were enterprise tools with license fees in the range of several hundred to more than a thousand dollars, so not really an option if you are not a company.
You can try OpenCppCoverage: https://github.com/OpenCppCoverage/OpenCppCoverage.
It is open source, designed for Visual Studio C++ and works well with Google Test. I already used successfully for mid size project (~500 000 lines of code).
Hope that help.
Disclaimer: I am the author of the tool.