test-driven-development

Write failing tests before implementing minimal code to pass them.

1|Updated Jan 28, 2025
One-click install
npx skills add https://github.com/josuenavarroaguado/josuenavarroaguado.github.io --skill test-driven-development-josuenavarroaguado
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: test-driven-development
Source: https://github.com/josuenavarroaguado/josuenavarroaguado.github.io/tree/main/.github/skills/test-driven-development
Command: npx skills add https://github.com/josuenavarroaguado/josuenavarroaguado.github.io --skill test-driven-development-josuenavarroaguado

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Test-driven development eliminates uncertainty about whether code changes work by forcing developers to write failing tests that specify desired behavior before implementation, preventing regressions and documenting expectations.

Core Features & Use Cases

  • Red–Green–Refactor Cycle: Guide to write a failing test, implement the minimal code to pass, and then refactor safely.
  • Prove-It Pattern for Bug Fixes: Reproduce reported bugs with tests before applying fixes so every repair is verifiable and regression-protected.
  • Testing Strategy & Scale: Guidance on the test pyramid, sizing tests (small/medium/large), and practical choices between real implementations, fakes, stubs, and mocks.
  • Use Case: Implement a new feature, add edge-case handling, or fix a bug by first authoring a failing test, validating the failure, applying the minimal fix, and ensuring the full suite remains green.

Quick Start

Write a failing test that reproduces the desired behavior, implement the minimal code to make it pass, and then run the full test suite to confirm all tests succeed.

Frequently Asked Questions about test-driven-development

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

FAQPage Schema
How do I write a failing test before implementing new functionality?

To write a failing test before implementing functionality, author a deterministic test specifying desired behavior, validate the failure, apply minimal code to pass, and run the full suite to confirm success. This red-green-refactor cycle prevents regressions.

What is the best way to reproduce a bug with a test before fixing it?

The best way to reproduce a bug with a test is using the prove-it pattern: author a failing test reproducing the reported behavior, validate the failure, apply the minimal fix, and ensure the full test suite remains green to prevent regressions.

How do I choose between stubs, mocks, and fakes when writing unit tests?

Choosing between stubs, mocks, and fakes depends on your testing strategy and test scale. Guidance covers the test pyramid, sizing tests as small, medium, or large, and making practical choices between real implementations and test doubles.

Can I use test-driven development for integration and end-to-end testing?

Yes, you can use test-driven development for integration and end-to-end testing. The workflow applies across unit, integration, and end-to-end test scopes, requiring deterministic tests runnable locally or in CI to verify behavior and prevent regressions.

When should I refactor code during the TDD cycle?

You should refactor code during the TDD cycle after writing a failing test and implementing the minimal code to pass. Refactoring safely at this stage improves code quality while maintaining green tests and preventing regressions.

Does test-driven development work for adding edge-case handling to existing behavior?

Test-driven development works for adding edge-case handling by first authoring a failing test specifying the edge case, validating the failure, applying the minimal code to pass, and ensuring the full test suite succeeds to prevent regressions.