Skip to content

C++ Testing with GoogleTest

Writes, fixes and debugs C++ tests using GoogleTest, CMake/CTest, coverage and sanitizers.

Repository
affaan-m/ECC
Stars
295,127
Licence
MIT
Files
1 file

What it does

When installed, this skill tells the AI agent to follow a specific test-first workflow for C++ projects (red, green, refactor) using GoogleTest and GoogleMock with CMake/CTest. It gives the agent project layout conventions, example test code, commands for running tests and filtering failures, and setup for code coverage and sanitizers such as AddressSanitizer. It also lists guardrails against flaky tests, such as avoiding sleep-based synchronization and fixed temporary paths.

Great for

  • C++ developers who want an AI agent to write or repair GoogleTest unit tests
  • Teams setting up CMake/CTest, coverage reports or sanitizer builds for a C++ project
  • Engineers diagnosing failing or flaky C++ tests in CI

Skip it if

  • Non-C++ projects or non-testing tasks, which the skill itself says it should not be used for
  • Feature implementation without test changes, since the skill is scoped to testing work
  • Projects that do not use GoogleTest or CMake: the examples assume both, so the agent would need to adapt them

Try asking

  • “Write GoogleTest unit tests for my C++ Add and Clamp functions and wire them into CTest.”
  • “Our UserStore tests are flaky in CI; help me find the cause and fix it without sleeps.”
  • “Set up gcov/lcov coverage for my CMake C++ project and show me how to generate an HTML report.”
  • “Enable AddressSanitizer and ThreadSanitizer builds to check my C++ tests for memory and race bugs.”
Step-by-step guide: how to use C++ Testing with GoogleTestInstall, first run, examples, tips and FAQs

Install in 3 steps

  1. 1

    Download the skill

    The ZIP contains the 1 original files, the MIT licence and an attribution note.

    cpp-testing.zip
  2. 2

    Add it to your agent

    Claude Code (all projects)

    mkdir -p ~/.claude/skills && unzip cpp-testing.zip -d ~/.claude/skills/

    Claude Code / Agent SDK (this project only)

    mkdir -p .claude/skills && unzip cpp-testing.zip -d .claude/skills/

    Claude apps (web/desktop): Settings → Capabilities → Skills → Upload skill, and choose the ZIP.

  3. 3

    Ask for the task

    No special command needed — the agent reads the skill's description and loads it when your request matches. Try one of the prompts above.

Get better results

  • Name the compiler and build system you use (GCC or Clang, CMake version) so the agent picks the matching coverage and sanitizer commands.
  • Ask for a single failing test to be re-run with --gtest_filter first, as the skill's debugging steps recommend.
  • Review the generated CMakeLists.txt before building, especially the googletest version pin, since the example fetches code from GitHub.

What's inside

  • SKILL.md

Redistributed unmodified from affaan-m/ECC under the MIT licence. The assessment was drafted with AI from the skill's files on 2026-10-29. Skills can instruct your agent to run code — read SKILL.md and any scripts before installing.