cpp-testing

Automate GoogleTest/GoogleMock setup with CMake/CTest for C++17/20 projects.

Updated Apr 4, 2026
One-click install
npx skills add https://github.com/mitul-bhatia/Vibes --skill cpp-testing-mitul-bhatia
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cpp-testing
Source: https://github.com/mitul-bhatia/Vibes/tree/main/.github/skills/cpp-testing
Command: npx skills add https://github.com/mitul-bhatia/Vibes --skill cpp-testing-mitul-bhatia

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill streamlines C++ testing workflows by providing guidance on writing unit and integration tests, configuring GoogleTest/GoogleMock with CMake/CTest, and diagnosing failing or flaky tests.

Core Features & Use Cases

  • Guides setting up GoogleTest/GoogleMock with CMake/CTest in modern C++ projects.
  • Provides patterns for unit tests, integration tests, fixtures, mocks, and test data organization.
  • Covers CI gating, sanitizer configurations, and test discovery via gtest_discover_tests.

Quick Start

Create a small sample project configured with GoogleTest/CTest and run the test suite to validate the workflow.

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 in a modern C++ project?

To set up GoogleTest with CMake, you configure CTest integration and use gtest_discover_tests for automatic test registration. This provides patterns for structuring test suites, fixtures, and mocks across C++17/20 projects.

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

Organizing C++ unit tests with GoogleMock involves using test fixtures and establishing a clear test data layout. This approach separates unit and integration tests while providing reusable mock patterns for dependency isolation.

Why are my GoogleTest tests failing to discover in CTest during CI?

GoogleTest discovery in CTest fails when gtest_discover_tests is not properly configured in your CMake setup. Ensuring correct CI gating commands and test discovery integration resolves these failing or flaky test issues.

Can I configure sanitizer runs and CI gates for C++ testing with CTest?

Yes, you can configure sanitizer runs and CI gates for C++ testing through CTest. This integration applies CI-friendly commands and test discovery to enforce testing standards across modern C++17 and C++20 projects.

How do I refactor an existing C++ test suite to use gtest_discover_tests?

Refactoring a C++ test suite to use gtest_discover_tests requires updating your CMake configuration to enable automatic test discovery. This modernizes test execution by integrating directly with CTest for robust CI gating.

When should I use GoogleMock fixtures for testing C++17 codebases?

You should use GoogleMock fixtures for C++17 codebases when tests require repeated setup and dependency isolation. Fixtures provide a structured baseline for test data organization and mock patterns across unit and integration tests.