# TDD
Test Last approach has shown its limitations over time since written tests are adapted to the code, introducing a confirmation bias. TDD adopts a Test First approach in which unit tests are written before code.
# Three Phases of TDD
- Red. Write a unit test in failure.
- Green. Write a code sufficient to pass this unit test. Solution does not have to be ideal or optimized but should aim to pass the test ASAP.
- Refactor. Don't modify the behavior, but code is refactored.
# Clean Test
A clean test is characterized by its readability. A unit test must contain one concept and one assertion.
- Fast : test must be fast to be executed often
- Independent : tests must be independent.
- Repeatable : test must be repeatable in different envs.
- Self-validating : test result must be either success or failure.
- Timely : test must be written just before production code is made.
← GIT Tips on webdesign →