Menu

Post image 1
Post image 2
Post image 3
Post image 4
1 / 4
0

How to Measure Code Coverage in C++ with Visual Studio 2026

DEV Community: cpp·Marco Hernandez·3 days ago
#d6WzFSVi
#dev#coverage#test#visual#studio#tests
Reading 0:00
15s threshold

About My Code I'm developing a video game in C++ using SDL3 — a cross-platform library that provides access to accelerated video, audio, controllers, and more. As part of development, I'm writing unit tests using a simple custom system that works like this: Tests are created by inheriting from a base Test class and implementing its run method. A custom Assert class handles assertions. A class called Vgx3TestRunner runs all tests explicitly. There's no automatic test discovery — if you write a new test, you need to register it manually: add a call to it in run() , and if it's a new test class, include it in Vgx3TestRunner . For context, this guide is written for Visual Studio 2026 on Windows 11 . The code itself should compile on Mac or Linux, but the coverage measurement steps are specific to Visual Studio 2026. Measuring Coverage Two things need to be done: Enable the /PROFILE linker flag. Run your tests and generate a coverage report.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More