cpp-testing

Write, update, and diagnose C++ tests with GoogleTest/GoogleMock in CMake/CTest workflows.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

C++ projects often struggle to keep tests reliable, up-to-date, and easy to diagnose when using GoogleTest/GoogleMock alongside CMake/CTest. This Skill provides an agent-focused workflow to write, update, and debug tests, enforce consistent testing practices, and streamline test maintenance across modern C++ codebases.

Core Features & Use Cases

  • TDD loop: red → green → refactor for C++ tests with structured test discovery.
  • CMake/CTest integration: guidance for stable test configuration, fixtures, and CI gating.
  • Code examples & patterns: unit tests, fixtures, mocks, and sample CI-ready layouts.
  • Sanitizers & diagnostics: easy enablement of ASAN/UBSAN/TSAN for memory and race detection.

Quick Start

Create a new C++ project configured with GoogleTest via CMake, then run cmake and ctest to execute the tests.

Frequently Asked Questions about cpp-testing

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

FAQPage Schema
How do I set up GoogleTest and GoogleMock with CMake and CTest?

To set up GoogleTest with CMake, configure your project to link the GoogleTest libraries and register test executables with CTest. This enables structured test discovery and execution within your C++ build workflow.

What is the best way to write C++ unit tests using test fixtures?

Writing C++ unit tests with test fixtures involves creating GoogleTest fixture classes to set up and tear down shared states. This approach ensures consistent testing practices and reusable test environments across multiple test cases.

How do I enable ASAN, UBSAN, and TSAN sanitizers in a CMake testing workflow?

To enable sanitizers in CMake, add compiler flags for ASAN, UBSAN, and TSAN in your CMake configuration. This integrates memory and race detection directly into your CTest execution cycle for safer diagnostics.

Can I use this workflow for both unit and integration tests in C++?

Yes, this C++ testing workflow supports both unit and integration tests. By leveraging CMake and CTest, you can manage test fixtures and apply consistent testing practices across different levels of application logic.

Why does my GoogleTest discovery fail in CI pipelines using CTest?

GoogleTest discovery may fail in CI if CMake is not configured properly for test execution. Ensuring stable CTest configuration and CI-ready test layouts helps reliably detect and run GoogleTest cases without missing executables.