cpp-testing

Diagnose and fix C++ test failures using GoogleTest/CMake/CTest.

1|Updated Apr 7, 2026
One-click install
npx skills add https://github.com/riftzen-bit/gemini-setup --skill cpp-testing-riftzen-bit
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cpp-testing
Source: https://github.com/riftzen-bit/gemini-setup/tree/main/skills/cpp-testing
Command: npx skills add https://github.com/riftzen-bit/gemini-setup --skill cpp-testing-riftzen-bit

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps developers write, configure, and debug C++ unit and integration tests using GoogleTest/GoogleMock and CMake/CTest to reduce time spent diagnosing failures, flaky tests, and CI test regressions.

Core Features & Use Cases

  • Test authoring & TDD: guidance for the red → green → refactor loop, test layout, fixtures, and when to choose mocks versus fakes.
  • Build and CI integration: instructions to integrate gtest_discover_tests with CTest, configure CMake test targets, and gate suites in CI.
  • Diagnostics & hardening: steps to enable ASan/UBSan/TSan, collect coverage with gcov/lcov or llvm-cov, and guardrails for flaky tests.
  • Use Case: Add a unit test for a failing parser, reproduce the failure locally with sanitizers enabled, and add a CI job that runs the fixed test suite and uploads coverage.

Quick Start

Build the project with CMake in Debug, enable AddressSanitizer, run the failing GoogleTest via ctest or the test binary, and report the failing assertion and stack trace.

Frequently Asked Questions about cpp-testing

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

FAQPage Schema
How do I integrate GoogleTest with CMake and CTest to run my C++ unit tests?

You can integrate GoogleTest with CMake by configuring test targets and using gtest_discover_tests with CTest, which registers tests automatically and allows you to reproduce failing assertions and stack traces locally.

How do I enable AddressSanitizer and UBSan builds in CMake to diagnose flaky C++ tests?

To diagnose flaky C++ tests, enable AddressSanitizer, UBSan, or TSan builds in CMake, then run the failing GoogleTest binary via ctest to capture memory errors and thread race conditions in the stack trace.

What is the best way to collect C++ code coverage with gcov or llvm-cov in a CMake project?

The best way to collect C++ coverage is to configure your CMake Debug build with gcov/lcov or llvm-cov instrumentation, run the test suite via CTest, and generate a report to identify untested code paths.

When should I use GoogleMock mocks versus fakes in my C++ test fixtures?

Use GoogleMock mocks in C++ test fixtures when verifying interaction sequences, and choose fakes when you need lightweight, stateful implementations to drive the red-green-refactor loop without coupling tests to call expectations.

Can I use this approach to gate C++ test suites in a CI pipeline and upload coverage reports?

Yes, you can gate C++ test suites in CI pipelines by running CTest with sanitizer builds enabled, ensuring reproducible test runs, and uploading the generated gcov or llvm-cov coverage artifacts for regression tracking.

Why does my gtest_discover_tests fail to register C++ tests in CTest?

Your gtest_discover_tests registration fails when the C++ test binary cannot execute at CMake configure time due to missing shared libraries or sanitizer runtime dependencies, requiring correct environment paths before CTest discovery.