test-driven-development

Implements the red-green-refactor TDD cycle for writing tests before production code.

3|Updated Aug 26, 2026
One-click install
npx skills add https://github.com/Fabric-Pro/fabric-oss --skill test-driven-development-fabric-pro
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: test-driven-development
Source: https://github.com/Fabric-Pro/fabric-oss/tree/main/.cursor/skills/test-driven-development
Command: npx skills add https://github.com/Fabric-Pro/fabric-oss --skill test-driven-development-fabric-pro

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Developers often write code first and tests later (or never), leading to regressions, unclear requirements, and fragile designs. This Skill enforces the red-green-refactor cycle so every feature starts with a failing test that defines expected behavior before implementation begins. ## Core Features & Use Cases - Red-Green-Refactor Workflow: Guides writing a failing test first, implementing minimal code to pass, then refactoring safely with tests green. - Testing Patterns Library: Covers descriptive test naming, the Arrange-Act-Assert pattern, fixtures, mocking external dependencies, exception testing, and async test handling with pytest. - Verification Checklist: Ensures tests were written before implementation, each test covers one behavior, and no untested code paths remain. - Use Case: When fixing a bug in user registration, write a failing regression test reproducing the bug, implement the minimal fix to make it pass, then refactor the surrounding code while the test suite guards against regressions. ## Quick Start Use the test-driven-development skill to implement a new user registration feature by writing the failing test first, then the minimal code to pass it, then refactoring.

Frequently Asked Questions about test-driven-development

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

FAQPage Schema
How do I start test-driven development on a new feature?▼

Begin with the simplest failing test that describes the desired behavior, run it to confirm it fails (red), write the minimal code to make it pass (green), then refactor while keeping tests green. Repeat this cycle for each new behavior.

How do I write a failing test first in pytest?▼

Write a test function asserting the expected outcome of code that does not exist yet, then run pytest to confirm it fails. Only after seeing the failure do you implement the minimal function or class needed to make the assertion pass.

How do I test exceptions and async code with pytest?▼

Use pytest.raises as a context manager to assert that specific exceptions are raised with expected messages. For async code, mark tests with @pytest.mark.asyncio and await the coroutine under test before asserting results.

When should I mock external dependencies in unit tests?▼

Mock external services like email senders, payment gateways, or HTTP APIs whenever the test should verify your code's behavior without triggering real side effects. Use mocker.patch to replace the dependency and assert it was called with expected arguments.

When should I not use strict TDD?▼

Strict TDD is less suitable for rapid prototyping, UI layout experimentation, exploratory coding with unfamiliar APIs, and trivial getters or setters. In those cases, write tests after implementation but before committing the code.