cpp-testing

Generates and diagnoses C++ tests using GoogleTest, GoogleMock, CMake, and CTest.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing reliable C++ tests requires choosing the right framework, mocking strategy, and build configuration, and mistakes lead to flaky tests, missed edge cases, and undetected memory or concurrency bugs. This Skill provides a structured workflow for designing, generating, and verifying C++ test suites. ## Core Features & Use Cases - Test Generation with GoogleTest/GoogleMock: Produces unit tests, fixtures, and mocks following a phased protocol covering context analysis, strategy selection, and edge-case design. - CMake/CTest Integration: Configures test discovery with gtest_discover_tests, coverage builds with gcov/lcov or llvm-cov, and sanitizer builds (ASan, UBSan, TSan). - Failure Diagnosis & Flaky Test Guardrails: Guides debugging of failing tests and enforces deterministic patterns like condition variables instead of sleeps. - Use Case: When asked to add tests for a C++ class with external dependencies, the Skill analyzes the code, decides between mocks and fakes, generates the test file, and provides the exact ctest commands to run it. ## Quick Start Ask the agent to write GoogleTest unit tests with mocks for a specific C++ class and provide the ctest command to run them.

Frequently Asked Questions about cpp-testing

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

FAQPage Schema
How do I write C++ unit tests with GoogleTest and CMake?▼

Create test files using TEST or TEST_F macros, link against GTest::gtest and GTest::gmock in CMake, and register tests with gtest_discover_tests. Run them with ctest --test-dir build --output-on-failure after building.

GoogleTest vs Catch2 vs doctest for C++ testing?▼

GoogleTest offers mature mocking via GoogleMock and deep CTest integration. Catch2 is header-only with expressive matchers, while doctest minimizes compile overhead. This Skill primarily targets GoogleTest but acknowledges Catch2 and doctest as alternatives.

How do I enable AddressSanitizer for C++ tests in CMake?▼

Add an ENABLE_ASAN option that appends -fsanitize=address -fno-omit-frame-pointer to compile and link options, then configure a separate build directory with -DENABLE_ASAN=ON. Similar options exist for UBSan and TSan.

Why are my C++ concurrency tests flaky?▼

Flaky concurrency tests usually come from using sleep for synchronization, shared mutable state, or unsanitized data races. Use condition variables or latches with bounded waits, deterministic seeds, and run ThreadSanitizer in CI.

When should I use mocks versus fakes in C++ tests?▼

Use GoogleMock mocks with EXPECT_CALL when verifying interactions at virtual interface boundaries. Prefer fakes for stateful behavior, and avoid mocking simple value objects to prevent coupling tests to implementation details.