Course outline · 0% complete

0/29 lessons0%

Course overview →

When TDD Helps (and When It Does Not)

lesson 4-3 · ~8 min · 12/29

An honest scorecard

TDD is a tool, not a religion. Where it shines:

  • clear specs: you know the expected outputs, like fizzbuzz or a tax rule, so tests write themselves
  • bug fixes: reproduce the bug as a failing test first, then fix. The red-to-green flip proves the fix, and the test guards against the bug returning forever
  • tricky pure logic: parsers, date math, pricing, anywhere edge cases breed

Where it fights you:

  • exploration: you do not know what you are building yet, so specs do not exist to test against
  • visual work: whether a layout looks right is not an assert
  • thin glue code: a one-line wrapper rarely earns a test

The pros' habit even outside strict TDD: never fix a bug without first writing the test that catches it. That single rule carries most of TDD's value.

Quiz

A user reports that invoices for exactly 100 items get the wrong discount. Following the bug-fix rule above, what is your very first action?

Problem

Complete the TDD mantra with its three beats in order: red, green, then a third word for cleaning up the code while tests stay passing. What is the third word?

Quiz

Which project is the WEAKEST fit for strict test-first TDD?