cpp-testing

Plan and run GoogleTest/GoogleMock C++ tests with CTest and CMake.

1|Updated Jan 30, 2021
One-click install
npx skills add https://github.com/fideguch/my_dotfiles --skill cpp-testing-fideguch
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cpp-testing
Source: https://github.com/fideguch/my_dotfiles/tree/main/claude/skills/cpp-testing
Command: npx skills add https://github.com/fideguch/my_dotfiles --skill cpp-testing-fideguch

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill guides engineers to write, update, and diagnose C++ tests, configure GoogleTest/CTest with CMake, and ensure reliable test coverage and sanitizers.

Core Features & Use Cases

  • TDD loop guidance (red → green → refactor) to structure tests around small, verifiable behaviors.
  • Comprehensive testing setup for C++ projects using GoogleTest/GoogleMock with CMake/CTest, including test discovery and fixtures.
  • Case studies and code examples covering basic unit tests, fixtures, mocks, and CI integration to gate changes.
  • Guidance on enabling sanitizers, test coverage, and robust test organization for maintainable code.

Quick Start

Configure your CMake project to enable GoogleTest, add tests following the examples, and run the test suite to verify results.

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 CTest with CMake for my C++ project?

To set up GoogleTest with CTest, configure your CMake project to enable GoogleTest, add test targets following structured examples, and run the test suite via CTest to validate your C++ production code.

What is the best way to structure C++ unit tests using GoogleMock fixtures?

The best way to structure C++ unit tests is following the TDD loop (red to green to refactor), using GoogleTest fixtures for setup and GoogleMock to isolate dependencies, ensuring small and verifiable behaviors.

Can I use CTest to run GoogleTest cases with sanitizers and code coverage?

Yes, CTest can run GoogleTest cases with sanitizers and code coverage by configuring CMake to enable optional sanitizer flags and coverage tooling during test discovery and execution.

Do I need GoogleMock to write integration tests for my C++ application?

GoogleMock is required to isolate dependencies when writing C++ integration tests, allowing you to validate production code interactions using mocks, fixtures, and CTest for CI gating tasks.

How does the TDD loop apply to C++ testing with CMake and GoogleTest?

The TDD loop applies by structuring C++ tests around small, verifiable behaviors: write a failing GoogleTest (red), implement code to pass (green), and refactor while maintaining CMake test discovery.