tdd

Guide test-driven development through red-green-refactor cycles for features and bug fixes.

Updated May 6, 2023
One-click install
npx skills add https://github.com/motoedie/.dotfiles --skill tdd-motoedie
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tdd
Source: https://github.com/motoedie/.dotfiles/tree/main/ai-tools/skills/tdd
Command: npx skills add https://github.com/motoedie/.dotfiles --skill tdd-motoedie

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps developers build software more reliably and with higher quality by adhering to the principles of Test-Driven Development (TDD), ensuring that code is written to meet specific, tested requirements.

Core Features & Use Cases

  • Red-Green-Refactor Loop: Guides users through the iterative cycle of writing failing tests, implementing minimal code to pass, and then refactoring.
  • Focus on Behavior: Emphasizes writing tests that verify observable behavior through public interfaces, not internal implementation details.
  • Use Case: When starting a new feature, use this Skill to guide the process of writing the first test, then the minimal code to pass it, and repeating this cycle until the feature is complete and well-tested.

Quick Start

Use the tdd skill to guide me through writing a test for a new user registration function.

Frequently Asked Questions about tdd

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

FAQPage Schema
How do I start test-driven development for a new software feature?

Test-driven development for a new feature starts by writing a failing integration test that verifies behavior through public interfaces. You then write minimal code to pass the test, and finally refactor the implementation while keeping tests green.

What is the red-green-refactor methodology in software development?

The red-green-refactor methodology is an iterative test-driven development cycle. Red involves writing a failing test, green means writing minimal code to pass it, and refactor means improving code quality while keeping the tests green.

Should I use mocking when writing integration-style tests?

You should avoid excessive mocking when writing integration-style tests. This test-driven development approach emphasizes verifying observable behavior through public interfaces rather than asserting internal implementation details, keeping tests robust during refactoring.

Can I use test-driven development for fixing existing software bugs?

Yes, you can use test-driven development for bug fixing. You start by writing an integration-style test that reproduces the bug through public interfaces, implement minimal code to fix it and pass the test, and then refactor the software.

Why focus on testing observable behavior instead of implementation details?

Focusing tests on observable behavior through public interfaces prevents test failures during refactoring. This test-driven development approach avoids implementation-specific assertions and excessive mocking, ensuring tests validate actual requirements without coupling to internal code.