cpp-testing

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

2|Updated Apr 1, 2024
One-click install
npx skills add https://github.com/bbaserdem/NixOS-Config --skill cpp-testing
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cpp-testing
Source: https://github.com/bbaserdem/NixOS-Config/tree/main/home-manager/batuhan/apps/claude/skills/cpp-testing
Command: npx skills add https://github.com/bbaserdem/NixOS-Config --skill cpp-testing

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill addresses the complexities of writing, debugging, and maintaining C++ tests, ensuring robust and reliable software through efficient testing practices.

Core Features & Use Cases

  • Test Writing & Debugging: Assists in creating new C++ tests (unit, integration) and diagnosing failures.
  • Test Configuration: Helps set up GoogleTest/GoogleMock with CMake/CTest for consistent test execution.
  • Coverage & Sanitizers: Guides on adding code coverage and enabling sanitizers for deeper diagnostics.
  • Use Case: You've written a new C++ feature and need to ensure it's thoroughly tested, including setting up mocks and ensuring test coverage.

Quick Start

Use the cpp-testing skill to write a new unit test for the calculate_average function in src/stats.cpp.

Frequently Asked Questions about cpp-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Does this testing workflow support CI integration for C++ projects?

Yes, the testing workflow supports CI integration by using CTest to execute your GoogleTest suites. This enables automated test runs, coverage reporting, and sanitizer checks directly within your continuous integration pipelines.

How do I set up GoogleTest and GoogleMock with CMake and CTest?

You can configure GoogleTest and GoogleMock integration with CMake and CTest by defining test targets and linking the framework libraries, ensuring consistent test execution and automated discovery of test cases across your C++ project.

What's the best way to isolate C++ unit tests and avoid flaky behavior?

To isolate C++ unit tests and eliminate flaky behavior, use mock objects to sever external dependencies and avoid hidden global state. This ensures tests run independently without side effects or unpredictable failures.

How do I add code coverage and enable sanitizers for C++ testing?

You can add code coverage and enable sanitizers by configuring compiler flags within your CMake build system. This provides deeper diagnostics for memory errors and tracks which code paths your C++ tests exercise.

Can I use this approach to diagnose failing C++ integration tests?

Yes, you can diagnose failing C++ integration tests by leveraging the framework's debugging capabilities. The setup helps identify mismatches in mocked interactions and isolate failures within your test execution workflow.

Does this testing workflow support CI integration for C++ projects?

Yes, the testing workflow supports CI integration by using CTest to execute your GoogleTest suites. This enables automated test runs, coverage reporting, and sanitizer checks directly within your continuous integration pipelines.