cpp-testing

Diagnose and fix flaky C++ tests with GoogleTest and CMake/CTest.

1|Updated Mar 6, 2026
One-click install
npx skills add https://github.com/khetansarvesh/ai_skills_repo --skill cpp-testing-khetansarvesh
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cpp-testing
Source: https://github.com/khetansarvesh/ai_skills_repo/tree/main/skills/cpp-testing
Command: npx skills add https://github.com/khetansarvesh/ai_skills_repo --skill cpp-testing-khetansarvesh

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you diagnose and fix failing or flaky C++ tests while reliably setting up GoogleTest/GoogleMock with CMake/CTest.

Core Features & Use Cases

  • Test workflow guidance: Apply a RED → GREEN → REFACTOR loop to implement the smallest correct fix.
  • CMake/CTest setup and execution: Use consistent discovery and test running patterns (including focused runs for a single suite).
  • Failure debugging and reliability safeguards: Reduce flakiness by improving isolation, determinism, and sanitizer-based diagnostics.

Quick Start

Ask the assistant to help you fix a failing or flaky GoogleTest test and update your CMake/CTest configuration so it discovers and runs reliably.

Frequently Asked Questions about cpp-testing

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

FAQPage Schema
How do I fix flaky GoogleTest tests in C++?

Fix flaky GoogleTest tests by applying a structured RED-GREEN-REFACTOR approach to implement the smallest correct fix while improving test isolation and determinism. Ensure your CMake and CTest configuration reliably discovers and runs the tests to prevent environmental flakiness.

How do I configure CMake and CTest to discover GoogleTest tests?

Configure CTest to discover GoogleTest tests by using the gtest_discover_tests command in your CMakeLists.txt file. This approach provides reliable test discovery at runtime rather than build time, ensuring tests are properly registered and executed within your CI pipeline.

How do I use sanitizers to debug C++ test failures?

Use sanitizers to debug C++ test failures by enabling them during your build process to detect memory leaks, race conditions, and undefined behavior. Run your GoogleTest suite with sanitizers active to surface hidden memory or concurrency issues causing tests to fail.

Can I run a single GoogleTest suite using CTest?

Yes, you can run a single GoogleTest suite using CTest by configuring focused test runs. Properly setting up gtest_discover_tests allows you to filter and execute specific test suites or individual cases without running the entire test binary, streamlining your debugging workflow.

What is the RED-GREEN-REFACTOR approach for C++ unit tests?

The RED-GREEN-REFACTOR approach for C++ unit tests is a structured workflow where you first write a failing test, implement the smallest correct fix to make it pass, and then refactor the code. This loop ensures reliable coverage when creating or updating GoogleTest tests.

Why does my CMake test discovery fail in CI pipelines?

CMake test discovery often fails in CI pipelines due to improper gtest_discover_tests configuration or missing runtime dependencies. Ensure your CMake setup uses deterministic and isolated test practices with correct CTest configuration to reliably discover and execute tests in CI environments.