cpp-testing

Create and configure C++ tests with GoogleTest, GoogleMock, CMake, and CTest.

Updated Jul 10, 2025
One-click install
npx skills add https://github.com/nubiv/my-nome --skill cpp-testing-nubiv
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cpp-testing
Source: https://github.com/nubiv/my-nome/tree/main/nix-darwin/config/claude/skills/cpp-testing
Command: npx skills add https://github.com/nubiv/my-nome --skill cpp-testing-nubiv

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill streamlines the process of writing, configuring, and debugging C++ tests, ensuring robust and reliable code.

Core Features & Use Cases

  • Test Development: Write new C++ unit and integration tests using GoogleTest/GoogleMock.
  • Configuration: Set up CMake/CTest for efficient test execution and discovery.
  • Debugging: Diagnose and fix failing or flaky tests, and enable sanitizers for deeper analysis.
  • Coverage: Integrate code coverage tools (gcov/lcov, llvm-cov) for comprehensive testing.
  • Use Case: When developing a new C++ feature, use this Skill to write corresponding unit tests, configure the build system to run them, and ensure they pass with code coverage before merging.

Quick Start

Use the cpp-testing skill to write a new GoogleTest for the calculate_sum function in src/calculator.cpp.

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

Set up GoogleTest with CMake by configuring CTest for automated test discovery and execution, linking GoogleTest libraries to your C++ build targets, and registering test binaries to run seamlessly during the build process.

How do I use GoogleMock to isolate dependencies when writing C++ unit tests?

Use GoogleMock to create mock objects simulating real class behaviors, allowing you to verify interactions and test C++ components in isolation without relying on actual external dependencies or complex system states.

What is the best way to generate code coverage reports for C++ using gcov and lcov?

Generate C++ code coverage by compiling with gcov coverage flags, executing your test suite via CTest, and processing the output with lcov to produce detailed HTML reports highlighting untested code paths.

Can I use sanitizers to debug flaky C++ tests in a CI pipeline?

Yes, integrate AddressSanitizer and other sanitizers into your CI pipeline to automatically detect memory errors and undefined behavior, helping diagnose and resolve flaky C++ tests during continuous integration workflows.

Why does my CMake test discovery fail to find GoogleTest binaries?

CMake test discovery fails when CTest configuration lacks proper test discovery commands or when GoogleTest binaries are not correctly linked and registered as test targets in your CMakeLists.txt build configuration file.

When should I use Test-Driven Development for C++ features?

Use Test-Driven Development for C++ features when you need robust code quality from the start, writing failing GoogleTest cases first and implementing minimal code to pass them before merging changes into the main branch.