TDD develops tests and code in a unique order. TDD
procedures work with units of program functionality. Units
are the smallest module of functionality and are usually in
the form of methods. The sequence of TDD is [3]:
1. Add a new test for an unimplemented unit of
functionality.
2. Run all previously written tests and see the newly
added test fail.
3. Write code that implements the new functionality.
4. Run all tests and see them succeed.
5. Refactor (rewrite to improve readability or
structure).
6. Start at the beginning (repeat).
As development continues, the programmer creates a suite
of unit tests that can be run automatically. As larger
modules (entire classes or packages, as opposed to single
methods) are completed, more tests may be added. The
programmers now have a full regression test suite to run
whenever changes are made to the system. Design changes
can be made with confidence, since if something breaks in
another part of the system, the regression tests are likely to
catch it.