test-driven-development

Enforce Red-Green-Refactor cycles with failing tests before production code.

1|Updated Dec 30, 2024
One-click install
npx skills add https://github.com/heitorfreitasferreira/.dotfiles --skill test-driven-development-heitorfreitasferreira
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: test-driven-development
Source: https://github.com/heitorfreitasferreira/.dotfiles/tree/main/.agents/skills/test-driven-development
Command: npx skills add https://github.com/heitorfreitasferreira/.dotfiles --skill test-driven-development-heitorfreitasferreira

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Writing feature and bugfix work without tests can lead to undetected regressions and brittle design. This skill promotes a test-first approach to ensure correct behavior and safer refactoring.

Core Features & Use Cases

  • Enforces the test-driven development cycle (Red-Green-Refactor) to guide implementation.
  • Reduces defect risk by requiring failing tests before production code.
  • Supports features like new functionality, bug fixes, and refactors with measurable correctness.

Quick Start

Write a failing test first, then implement the minimum code needed to make it pass.

Frequently Asked Questions about test-driven-development

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

FAQPage Schema
How do I implement test-driven development to prevent undetected regressions?

Test-driven development prevents regressions by enforcing a test-first cycle. You write minimal failing tests before production code, implement just enough logic to pass, and iterate Red-Green-Refactor until the codebase is clean and maintainable.

What is the Red-Green-Refactor cycle in software testing?

The Red-Green-Refactor cycle is the core of test-driven development. Red means writing a failing test, Green involves implementing minimum production code to pass the test, and Refactor means cleaning up the code while ensuring behavior remains verified.

Can I use test-first approaches for fixing bugs and refactoring existing features?

Yes, test-first approaches support fixing bugs and refactoring by requiring measurable correctness. You write failing tests that validate the expected behavior, implement the bugfix or refactor, and verify no regressions occur during the process.

What's the best way to start writing unit tests before coding new features?

The best way to start writing unit tests is to write a single failing test first that defines the desired behavior. Then, implement the minimum production code needed to make that test pass, and repeat the cycle for each new functionality.

Why does writing production code without unit tests lead to brittle design?

Writing production code without unit tests leads to brittle design because behavior is not verified by tests. Without a test-first approach, implementing features and bugfixes introduces undetected regressions and makes future refactoring unsafe.

Do I need specific testing frameworks to apply the test-driven development cycle?

No specific testing frameworks are required to apply the test-driven development cycle. The approach focuses on the process of writing minimal failing tests first and iterating code to pass them, making it applicable across any software testing environment.