test-driven-development

Guides test-first development using the RED-GREEN-REFACTOR cycle across any language or test framework.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Code changes made without tests ship unverified behavior, and bug fixes without reproduction tests leave regressions unguarded. This Skill enforces a disciplined test-first workflow so every behavior change is proven by a failing-then-passing test. ## 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 the fix, guaranteeing the fix actually works. - Stack Discovery: Detects the repository's own test runner and conventions (npm, Gradle, Cargo, pytest, Go) instead of assuming defaults. - Use Case: A bug report says completing a task doesn't set its timestamp. Write a failing test that asserts completedAt is set, watch it fail, implement the fix, and confirm the test passes with the full suite green. ## Quick Start Use test-driven development to implement this feature, starting with a failing test that describes the expected behavior.

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 on a bug fix?

Write a test that reproduces the bug first and confirm it fails, then implement the fix and confirm the test passes. This Prove-It Pattern guarantees the fix works and guards against future regressions.

What is the RED-GREEN-REFACTOR cycle in TDD?

RED means writing a failing test that defines 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 mocks as a last resort. Mock only when the real dependency is too slow, non-deterministic, or has uncontrollable side effects like external APIs or email sending.

Does TDD apply to languages other than JavaScript and TypeScript?

Yes, the TDD cycle is universal across languages. The workflow is identical once you discover the project's own tooling, whether that is Gradle, Cargo, pytest, Go, or a Makefile-based test command.

When should I not write tests first?

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

Why do my tests pass but production still breaks?

Over-mocking is the usual cause: tests that verify method calls instead of outcomes pass even when real behavior is broken. Test state and outputs rather than internal interactions, and prefer real implementations at boundaries.