tdd

Guide test-driven development with red-green-refactor loops and vertical tracer bullets.

88|9|Updated Jul 16, 2020
One-click install
npx skills add https://github.com/docs-plus/docs.plus --skill tdd-docs-plus
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tdd
Source: https://github.com/docs-plus/docs.plus/tree/main/.agents/skills/tdd
Command: npx skills add https://github.com/docs-plus/docs.plus --skill tdd-docs-plus

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill eliminates the common pain points of writing brittle tests that break during code refactors, implementing features with insufficient test coverage, and following inefficient horizontal slicing workflows that produce tests for imagined rather than actual user-facing behavior.

Core Features & Use Cases

  • TDD Workflow Guidance: Enforces the red-green-refactor loop with vertical tracer bullet cycles to ensure each test verifies real, observable behavior.
  • Anti-Pattern Prevention: Explicitly warns against horizontal slicing and implementation-detail testing to avoid low-quality, fragile test suites.
  • Best Practice References: Includes actionable guidance for deep module design, testable interface creation, appropriate system-boundary mocking, and refactor candidate identification.
  • Use Case: For example, when building a new user authentication feature, use this Skill to write a single test for successful login first, implement minimal code to pass it, then iterate on additional behaviors like password reset or failed login handling without writing tests that break when internal code structure changes.

Quick Start

Ask the AI to implement the new user profile editing feature using test-driven development, starting with a test for successful profile updates with valid user input.

Frequently Asked Questions about tdd

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

FAQPage Schema
Why do my unit tests break during refactoring even when user-facing behavior hasn't changed?

Unit tests break during refactoring when they are coupled to implementation details rather than observable behavior. Test-driven development resolves this by enforcing deep module interface design and appropriate system-boundary mocking to ensure tests remain refactor-safe.

How do I implement a new feature using test-driven development?

Implement features using test-driven development by following the red-green-refactor loop with vertical tracer bullet cycles. Write a single test for actual user-facing behavior, implement minimal code to pass it, then iterate on additional behaviors like edge cases.

What is the difference between horizontal slicing and vertical tracer bullets in TDD?

Horizontal slicing in TDD creates tests for imagined internal layers rather than actual user-facing behavior, producing fragile suites. Vertical tracer bullets instead slice through all layers to verify real observable behavior end-to-end, reducing test maintenance overhead.

When should I use mocks at the system boundary during integration testing?

Use mocks at the system boundary during integration testing to isolate external dependencies and verify actual user-facing behavior. Appropriate system-boundary mocking prevents implementation-coupled tests that fail during refactors while maintaining reliable test coverage.

How do I write refactor-safe tests for a user authentication feature?

Write refactor-safe tests for user authentication by starting with a single test for successful login, implementing minimal code to pass, then iterating on behaviors like password reset. This test-first approach verifies real observable behavior without coupling to internal structure.