cpp-testing

Automate GoogleTest/CTest setup and integration for modern C++ projects.

8|Updated Apr 9, 2026
One-click install
npx skills add https://github.com/D0NMEGA/donnyclaude --skill cpp-testing-d0nmega
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cpp-testing
Source: https://github.com/D0NMEGA/donnyclaude/tree/main/packages/skills/cpp-testing
Command: npx skills add https://github.com/D0NMEGA/donnyclaude --skill cpp-testing-d0nmega

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Writing and maintaining robust C++ tests (GoogleTest/CTest) across modern C++ projects can be error-prone and time-consuming. This skill provides a structured workflow to configure tests, integrate with CMake/CTest, and apply best practices like test doubles, fixtures, and sanitizers to ensure reliable test runs.

Core Features & Use Cases

  • Test layout & conventions: guide for unit/integration test organization (tests/unit, tests/integration) and common patterns with GoogleTest/GoogleMock.
  • CMake/CTest integration: instructions to wire GoogleTest into CMake and discover tests with CTest for CI reliability.
  • Deterministic tests & best practices: use of fixtures, dependency injection, and isolation to avoid flakiness.
  • Sanitizers & coverage guidance: enabling ASan/UBSan/TSan and collecting coverage data to improve code quality.
  • Use Case: onboarding a new C++ project with a standard test setup and CI gating.

Quick Start

Run the C++ test suite via CTest to verify the GoogleTest/CTest setup.

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 for CI?

Integrating GoogleTest with CMake and CTest involves configuring your CMakeLists.txt to link the GoogleTest library and registering tests via gtest_discover_tests for automated CI execution. This enables reliable test discovery and reporting within standard build pipelines.

What is the best way to organize C++ unit and integration tests?

Organizing C++ tests involves separating unit and integration tests into dedicated directories, such as tests/unit and tests/integration. This convention streamlines test management, clarifies test scope, and aligns with standard GoogleTest patterns for better project maintainability.

How do I enable sanitizers like ASan and UBSan in a C++ test suite?

Enabling sanitizers like ASan and UBSan requires configuring your CMake build with specific compiler flags to detect memory errors and undefined behavior during test execution. This integration improves code quality by catching hidden bugs during automated testing.

Why are my C++ unit tests flaky and how do I make them deterministic?

Flaky C++ unit tests often stem from unmanaged dependencies or shared state; making them deterministic requires using GoogleTest fixtures and dependency injection to isolate test environments. This ensures consistent test execution and reliable CI gating.

Can I use GoogleMock for test doubles in a C++17 or C++20 project?

Yes, you can use GoogleMock for test doubles in C++17 and C++20 projects by integrating it alongside GoogleTest within your CMake configuration. It provides robust mocking capabilities to isolate components and verify interactions during unit testing.