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://video2.skills-academy.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,612 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.
336 questions
{count} votes