DEV Community

SCHREIBER Christophe
SCHREIBER Christophe

Posted on

3 1

Test Driven Development in 1000 characters

Test Driven Development (TDD) is a practice of Extreme Programming consisting in writing tests before production code to guarantee the code quality.

Development process is divided in 3 steps:

  • Red: write a failing test
  • Green: write the minimum production code required to make the test pass, all shortcuts are allowed
  • Refactor: clean the mess of the code you just wrote to make it clean, improve the design

Since no production code is added before a test covers a usecase, test coverage is as close as possible to 100%.

Moreover, TDD promotes the usage of clean code principles thanks to the refactoring stage.

It can also help to make a clean design appear progressively. As Uncle Bob says: "as the tests become more specific, the code becomes more generic".

TDD helps team to write code that is easier to maintain and less risky to deliver.

TDD is often difficult to learn, especially on real life projects. Code katas are helpful to master this practice progressively with more simple use cases.

AWS Q Developer image

Your AI Code Assistant

Automate your code reviews. Catch bugs before your coworkers. Fix security issues in your code. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more