test-driven-development
Drives development with tests. Use when implementing any logic, fixing any bug, or changing any behavior. Use when you need to prove that code works, when a bug report arrives, or when you're about to modify existing functionality.
Author
Category
Development ToolsInstall
Hot:61
Download and extract to your skills directory
Copy command and send to AI Agent for auto-install:
Download and install this skill https://openskills.cc/api/download?slug=addyosmani-skills-test-driven-development&locale=en&source=copy
Test-Driven Development (TDD)
Skill Overview
Test-driven development is a development approach in which tests are written before code. It ensures code quality through the red-green-refactor cycle and is suitable for implementing new features, fixing bugs, and refactoring code.
Applicable Scenarios
Core Features
Frequently Asked Questions
What is the TDD red-green-refactor cycle?
Red-green-refactor is the core workflow of TDD: In the red phase, first write a failing test to prove that the functionality is missing; in the green phase, write the simplest code necessary to make the test pass; in the refactor phase, improve the code structure under the protection of the tests. This cycle is repeated continuously to ensure that every line of code is covered by tests.
Why should you write a test before fixing a bug?
Directly modifying the code may only make the problem appear to be fixed, without proving that the fix is effective or that it will not introduce new issues. Writing a failing test first clearly reproduces the bug. When the test passes after the fix, it proves that the fix works, and any future regression will be immediately caught by the test. This is the “prove it” pattern.
What is the difference between unit tests and integration tests?
Unit tests target the pure logic of a single function or class and do not depend on external resources such as databases, networks, or file systems. They run quickly, typically within milliseconds. Integration tests verify that multiple components work together or that operations crossing system boundaries—such as API calls and database reads and writes—function correctly. They are slower but cover real interactions. According to the testing pyramid, most tests should be fast unit tests.