cpp-testing

Diagnose and fix failing or flaky C++ tests with GoogleTest and CMake.

Updated Feb 5, 2026
One-click install
npx skills add https://github.com/gugug168/claudecode-tutorial --skill cpp-testing-gugug168
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cpp-testing
Source: https://github.com/gugug168/claudecode-tutorial/tree/main/everything-claude-code-learning/02-Skills/cpp-testing
Command: npx skills add https://github.com/gugug168/claudecode-tutorial --skill cpp-testing-gugug168

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps developers write, run, and stabilize C++ unit and integration tests by describing workflows and diagnostics for GoogleTest and GoogleMock with CMake and CTest. It reduces time spent reproducing and debugging failing or flaky tests, configuring CI test discovery, and collecting coverage and sanitizer outputs.

Core Features & Use Cases

  • TDD guidance: follow the red → green → refactor loop and craft focused failing tests to drive minimal, safe changes.
  • CMake and CTest integration: fetch and pin GoogleTest, configure targets, and use gtest_discover_tests for stable test discovery and CI gating.
  • Debugging and stabilization: reproduce single failures with gtest filters, enable sanitizers to detect memory and race errors, and add scoped logging to narrow root causes.
  • Coverage workflows: target-level coverage flags for gcov/lcov and llvm-cov workflows for actionable reports in CI.
  • Flaky test guardrails: avoid sleeps, use condition variables, unique temp directories, deterministic seeds, and separate unit vs integration tests.

Quick Start

Build a Debug test target with sanitizers enabled and run the failing test via CTest to reproduce the failure and capture sanitizer output.

Frequently Asked Questions about cpp-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I debug flaky GoogleTest tests using CMake and CTest?

To debug flaky GoogleTest tests with CMake and CTest, reproduce single failures using gtest filters and enable sanitizers to detect memory and race errors. You can also add scoped logging to narrow down root causes and stabilize your C++ test suite.

What is the best way to configure CMake targets for gtest_discover_tests?

Configuring CMake targets for gtest_discover_tests involves fetching and pinning GoogleTest, setting up your test targets, and using gtest_discover_tests for stable test discovery. This approach ensures reliable CI gating and automated test execution in your C++ projects.

How do I collect C++ code coverage with gcov and llvm-cov in CI?

Collect C++ code coverage with gcov and llvm-cov in CI involves applying target-level coverage flags during your CMake build. This instrumentation generates actionable coverage reports, helping you track test effectiveness and untested code paths.

Can I use sanitizers with CTest to find memory and race errors?

Yes, you can use sanitizers with CTest to find memory and race errors in C++17/20 projects. Build a Debug test target with sanitizers enabled and run the failing test via CTest to reproduce the failure and capture sanitizer output for diagnosis.

How do I avoid flaky C++ integration tests in CI pipelines?

To avoid flaky C++ integration tests in CI pipelines, avoid sleeps and use condition variables for synchronization. Additionally, use unique temp directories, deterministic seeds, and separate unit tests from integration tests to ensure reliable and reproducible CI workflows.

Does this workflow support Test-Driven Development for C++17 and C++20?

Yes, this workflow supports TDD for C++17 and C++20 projects by guiding you through the red, green, and refactor loop. It helps you craft focused failing tests to drive minimal, safe changes to your codebase using GoogleTest and GoogleMock.