test-driven-development

Guides test-first development using the red-green-refactor cycle for code changes and bug fixes.

5|Updated Mar 5, 2024
One-click install
npx skills add https://github.com/TRAPZZY/God-Eyes --skill test-driven-development-trapzzy
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: test-driven-development
Source: https://github.com/TRAPZZY/God-Eyes/tree/main/.skills/test-driven-development
Command: npx skills add https://github.com/TRAPZZY/God-Eyes --skill test-driven-development-trapzzy

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Code changes and bug fixes often ship without proof they work, leading to regressions and untested behavior. This Skill enforces a disciplined workflow where a failing test is written before any implementation, so every behavior change is verified and guarded against future breakage. ## Core Features & Use Cases - Red-Green-Refactor Cycle: Write a failing test first, implement the minimal code to pass it, then refactor with tests staying green. - Prove-It Pattern for Bug Fixes: Reproduce any reported bug with a failing test before attempting a fix, creating a permanent regression guard. - Test Pyramid & Sizing Guidance: Allocate effort across unit, integration, and E2E tests, and classify tests by resource constraints (small, medium, large). - Use Case: A bug report says completing a task does not set its timestamp. Write a reproduction test that fails, implement the fix, watch the test pass, then run the full suite to confirm no regressions. ## Quick Start Use the test-driven-development skill to write a failing test for the new feature before implementing it.

Frequently Asked Questions about test-driven-development

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

FAQPage Schema
How do I practice test-driven development when fixing a bug?▼

Write a test that reproduces the bug first and confirm it fails, then implement the fix and confirm the test passes. Finally run the full test suite to verify no regressions were introduced.

What is the red-green-refactor cycle in TDD?▼

Red means writing a failing test for the desired behavior, green means writing the minimal code to make it pass, and refactor means cleaning up the implementation while keeping tests green. The cycle repeats for each new behavior.

Should I use mocks or real implementations in unit tests?▼

Prefer real implementations first, then fakes, stubs, and finally interaction mocks. Reserve mocks for dependencies that are slow, non-deterministic, or have uncontrollable side effects like external APIs or email sending.

When should I not write tests before code?▼

Skip TDD for pure configuration changes, documentation updates, or static content changes with no behavioral impact. Any change that alters logic or behavior should start with a failing test.

Why do my tests break every time I refactor code?▼

Tests that assert on internal method calls or implementation details break during refactoring even when behavior is unchanged. Assert on inputs and outputs (state-based testing) instead of interaction sequences.

How many E2E tests should a test suite have?▼

Follow the test pyramid: roughly 80% unit tests, 15% integration tests, and 5% E2E tests. Limit E2E tests to critical user flows since they are slow and expensive to maintain.