How do I enable coverage reports with MSVC?

To enable coverage reports with MSVC (Microsoft Visual C++), you need to configure your project settings to generate the coverage data. Here’s how you can do it:

1. Open your project in Visual Studio.

2. Go to the project properties by right-clicking on the project in Solution Explorer and selecting 'Properties'.

3. Navigate to 'C/C++' -> 'General'.

4. Set the 'Enable Code Coverage' option to 'Yes'.

5. Then, go to 'Linker' -> 'Debugging' and make sure 'Generate Debug Info' is set to 'Yes (/DEBUG)'.

6. Rebuild your project to ensure coverage data is collected.

7. Run your tests using the testing framework of your choice.

8. Finally, you can use tools like OpenCppCoverage to generate HTML reports from the coverage data collected by the Visual Studio.


MSVC Code Coverage Visual Studio C++ Coverage Reports OpenCppCoverage