Back to list
Lv.3

Test-Driven Development

Test-Driven Development

A development method where you write tests before the code and build the program up in small, checked steps.

In Simple Terms

Test-driven development is a way of building software where you start by writing a test that checks whether the program works correctly, before you write the program itself. You repeat three steps: write a test that fails, write code that makes it pass, and then tidy up the code. That way you build features up little by little. Because you can quickly check whether features that used to work got broken when you change the code, it's sometimes used when you want to keep quality high while you keep developing.

Behind the Name

The "driven" in test-driven development means that something is pushing the work forward, and here that something is the tests. You write the tests first and let them guide each step, so they steer the whole development process. It's sometimes shortened to TDD, using the first letter of each word.

Take a Closer Look!

Test-driven development is a way of building software where you write a test first, one that checks whether the program works correctly, before you write the program itself.
Put simply, you set the "passing grade" first, and then build the thing that meets it, little by little.

More specifically, you repeat three steps in short cycles. First, you write a test for a feature that doesn't exist yet and run it, making sure it fails (on purpose!).
Next, you write just enough code to pass that test, so the test passes. Finally, you tidy up any messy parts of the code without changing how it behaves, and then move on to the test for the next feature.

Because you keep slipping in small checks like this, you'll notice right away if a change breaks something that used to work. Writing the test first also makes your goal clear: "What do I actually want this program to do?"
That's why it's used in software development settings where teams want to add features or rework code while keeping quality high.

CategoryProgramming