cpp-testing

Configure CMake/CTest with gtest_discover_tests for C++17/20 tests.

Updated Mar 24, 2026
One-click install
npx skills add https://github.com/Oruga420/claude-code-skills --skill cpp-testing-oruga420
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: cpp-testing
Source: https://github.com/Oruga420/claude-code-skills/tree/main/cpp-testing
Command: npx skills add https://github.com/Oruga420/claude-code-skills --skill cpp-testing-oruga420

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Provides a clear, repeatable workflow for writing, running, and diagnosing C++ unit and integration tests so teams can catch regressions early and reduce flaky failures in CI.

Core Features & Use Cases

  • TDD workflow: guidance for red→green→refactor cycles to add tests and minimal fixes.
  • CMake/CTest integration: patterns for gtest_discover_tests, test labels, CI gating, coverage, and sanitizer builds.
  • Debugging & reliability: strategies for reproducing failures, isolating flaky tests, and enabling sanitizers and coverage reporting.

Quick Start

Use the cpp-testing skill to add a failing GoogleTest for a new function, configure CMake/CTest to discover and run it, and run the test locally to reproduce the failure.

Frequently Asked Questions about cpp-testing

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

FAQPage Schema
How do I configure CMake and CTest to discover and run GoogleTest cases?▼

To configure CMake and CTest, use gtest_discover_tests to automatically register GoogleTest cases for execution. This enables test discovery, CI gating, and consistent local test running across modern C++17/20 projects.

What is the best way to add coverage and sanitizer flags to a C++ test build?▼

Add coverage and sanitizer flags directly within your CMake build configuration. This enables detailed code coverage reporting and memory error detection during test execution to catch regressions early.

How do I isolate flaky C++ tests in a CI pipeline?▼

Isolate flaky C++ tests by applying debugging strategies to reproduce failures locally and enabling sanitizers to detect hidden memory issues. This reduces intermittent CI failures and produces reproducible test signals.

Can I use GoogleTest for both unit and integration testing in modern C++?▼

Yes, you can use GoogleTest for both unit and integration testing in C++17/20 projects. Combined with CTest, it provides a repeatable workflow for writing, running, and diagnosing tests to catch regressions early.

How do I start a TDD workflow when adding a new C++ function?▼

Start a TDD workflow by following the red-green-refactor cycle: write a failing GoogleTest for the new function, configure CMake to run it, and apply the minimal fix to pass. This ensures reliable test-driven development.

Why does my CTest setup fail to reproduce a GoogleTest failure locally?▼

CTest may fail to reproduce a GoogleTest failure locally due to missing sanitizer flags or inconsistent environments. Apply test discovery patterns and enable sanitizer builds to generate reproducible CI test signals.