test-driven-development

Write failing tests before implementation using the red-green-refactor cycle.

Updated Sep 7, 2024
One-click install
npx skills add https://github.com/Asylcreek/home-manager --skill test-driven-development-asylcreek
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: test-driven-development
Source: https://github.com/Asylcreek/home-manager/tree/main/dots/agents/skills/test-driven-development
Command: npx skills add https://github.com/Asylcreek/home-manager --skill test-driven-development-asylcreek

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

When implementing features or fixing bugs, teams often code without a clear behavioral contract, which can lead to regressions. Test-driven development enforces writing tests first to define expected behavior and guide implementation.

Core Features & Use Cases

  • Red-Green-Refactor workflow: write a failing test, make it pass, then clean up.
  • Behavioral documentation through tests: tests encode the intended usage and edge cases.
  • Broad applicability: useful for features, bug fixes, and refactors across projects.

Quick Start

Provide a failing test first, then implement just enough code to pass it.

Frequently Asked Questions about test-driven-development

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

FAQPage Schema
What is test-driven development and how does the red-green-refactor cycle work?

Test-driven development is a practice of writing failing tests before implementation to enforce a red-green-refactor cycle, ensuring code changes are minimal and behavior is verified before refactoring.

How do I write tests before implementation to prevent regressions?

To prevent regressions, write a failing test that defines expected behavior first, then implement just enough code to pass it, and finally clean up the code while ensuring the test stays green.

Do I need a specific testing framework to practice test-driven development?

Test-driven development requires a testing framework to execute the red-green-refactor cycle, but it does not mandate a specific tool, making it broadly applicable across software projects.

Can I use test-driven development for bug fixes and refactors, not just new features?

Test-driven development is useful for feature development, bug fixes, and refactors across projects, encoding intended usage and edge cases into behavioral documentation whenever verifying behavior is essential.

Why should I write failing tests first instead of coding and testing later?

Writing failing tests first prevents guessing by defining a clear behavioral contract upfront, which guides implementation and prevents regressions that often occur when coding without defined expectations.