TDD
TDD
ELI5 — The Vibe Check
TDD means you write the test BEFORE you write the code. It sounds backwards but it's like writing your recipe before cooking — you know exactly what the dish should taste like before you start. Red (test fails), green (make it pass), refactor (clean it up).
Real Talk
Test-Driven Development is a software development methodology where you write a failing test first, then write the minimum code to make it pass, then refactor. The cycle is Red-Green-Refactor. It forces small, testable, well-defined units of code.
Show Me The Code
// 1. Write failing test (RED)
test('greet returns hello', () => {
expect(greet('Alice')).toBe('Hello, Alice!');
});
// 2. Write code to pass (GREEN)
function greet(name) {
return `Hello, ${name}!`;
}
When You'll Hear This
"We practice strict TDD — no code without a failing test first." / "TDD slows me down at first but saves hours of debugging."
Related Terms
BDD (BDD)
BDD is like writing your tests in plain English so your non-coder boss can also understand them.
Red-Green-Refactor
Red-Green-Refactor is the TDD dance: Red means write a test that FAILS (it's red in the output).
Test-Driven Development (TDD)
Test-Driven Development is a discipline where you write your tests before your actual code.
Unit Test
A unit test is like checking that one single LEGO brick isn't broken before you use it in your big castle.