How to get Code Coverage in Visual Studio 2022 with CMake Cpp Projects with a Windows Compiler

Hoad, Tom 0 Reputation points
2024-05-28T09:01:11.2366667+00:00

I have a Cpp project that is being built with the MSVC compiler and using CMake. I need a code coverage solution, preferably one that either provides detailed reports or in Visual Studio code highlighting that is possible using CMake.

So far I have tried using a Linux compiler and GCOVR/GCC to create these reports, but I am looking for a solution for a Windows compiler, so cannot use the GCC compiler flags.

This need to be able to work in not just Visual Studio Enterprise as the current suggestion requires: https://learn.microsoft.com/en-us/visualstudio/test/using-code-coverage-to-determine-how-much-code-is-being-tested?view=vs-2022&tabs=csharp#use-code-coverage-to-determine-how-much-code-is-being-tested

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,761 questions
Visual Studio Testing
Visual Studio Testing
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Testing: The act or process of applying tests as a means of analysis or diagnosis.
351 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.