Promptles
Testing & Quality

TDD (Test-Driven Development)

intermediate

Definition

A backwards-feeling habit: write the test first, then write just enough code to make the test pass, then clean up. The discipline forces you to think about how your code should behave before you start writing it, which often produces simpler designs and fewer surprises later.

In the wild

A developer is about to write a function that turns a name like 'Hello World' into 'hello-world' for a URL. Before writing the function, she writes a test that says 'I expect hello-world to come out.' She then writes the smallest function that makes the test pass. And only then thinks about whether to clean it up.

More from Testing & Quality