cpp-testing

Develop and execute C++ tests with GoogleTest and GoogleMock.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

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

Core Features & Use Cases

  • Test Writing & Debugging: Guides through creating unit and integration tests using GoogleTest and GoogleMock.
  • Build System Integration: Provides examples for integrating tests with CMake and CTest.
  • Coverage & Sanitizers: Demonstrates how to enable code coverage and sanitizers for enhanced quality assurance.
  • Use Case: When developing a new C++ feature, use this Skill to write TDD-style tests, configure CMake to build them, and run them with coverage and address sanitizer enabled.

Quick Start

Use the cpp-testing skill to write a basic GoogleTest for a C++ function.

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 into a CMake project?

To integrate GoogleTest with CMake, you configure your CMakeLists.txt to find the GoogleTest package, link the test executable against the gtest_main library, and register it with CTest using add_test to run tests during the build process.

What is the best way to write C++ unit tests with GoogleMock?

Writing C++ unit tests with GoogleMock involves creating test fixtures using the TEST_F macro and defining mock classes with MOCK_METHOD to simulate interface behaviors, allowing you to verify interactions and isolate dependencies for robust integration testing.

Can I enable code coverage and sanitizers when running C++ tests with CTest?

Yes, you can enable code coverage and sanitizers in CTest by configuring your CMake build with specific compiler flags like -fsanitize=address for sanitizers and -coverage for coverage, ensuring quality assurance data is collected during test execution.

How does test-driven development work for C++ features using GoogleTest?

Test-driven development in C++ using GoogleTest requires writing failing tests before implementation, configuring CMake to build the test targets, and iterating on your code until all CTest assertions pass with sanitizers enabled to ensure robustness.

Do I need CMake to run GoogleTest in my C++ project?

While CMake is not strictly required to run GoogleTest, it is the recommended approach for build system integration because it pairs natively with CTest to automate test execution, manage dependencies, and streamline the configuration of coverage and sanitizers.

Why are my GoogleTest failures hard to debug in C++?

GoogleTest failures are often caused by memory errors or undefined behavior. Compiling your C++ tests with address sanitizers enabled through CMake helps detect memory leaks and out-of-bounds access, providing precise diagnostics to resolve debugging issues.