Sign in
Explore
Prompts · PromptTesting & SecurityReviewed

cpp-test

Enforce TDD workflow for C++. Write GoogleTest tests first, then implement. Verify coverage with gcov/lcov.

Kind
Prompt
Works with
Claude Code, Codex
Languages
C / C++
Source
affaan-m/ECC @ d3b8a3e90890
Path
commands/cpp-test.md
License
MIT
Jobs
Testing, Implementation, Guardrails
InstallCopy it from the source repository, or sign in and let the assistant adapt it for your project.
# C++ TDD Command

This command enforces test-driven development methodology for C++ code using GoogleTest/GoogleMock with CMake/CTest.

## What This Command Does

1. **Define Interfaces**: Scaffold class/function signatures first
2. **Write Tests**: Create comprehensive GoogleTest test cases (RED)
3. **Run Tests**: Verify tests fail for the right reason
4. **Implement Code**: Write minimal code to pass (GREEN)
5. **Refactor**: Improve while keeping tests green
6. **Check Coverage**: Ensure 80%+ coverage

## When to Use

Use `/cpp-test` when:
- Implementing new C++ functions or classes
- Adding test coverage to existing code
- Fixing bugs (write failing test first)
- Building critical business logic
- Learning TDD workflow in C++

## TDD Cycle

```
RED     → Write failing GoogleTest test
GREEN   → Implement minimal code to pass
REFACTOR → Improve code, tests stay green
REPEAT  → Next test case
```

## Example Session

````
User: /cpp-test I need a function to validate email addresses

Agent:
# TDD Session: Email Validator

## Step 1: Define Interface

```cpp
// validator/email.hpp
#pragma once
#include <string>
#include <expected>

enum class EmailError {
    Empty,
…