...write unit tests before the writing production code.
Three Laws of TDD (R.C. Martin)
- You may not write production code until you have written a failing unit test.
- You may not write more of a unit test than is sufficient to fail, and not compiling this failing.
- You may not write more production code than is sufficient to pass the currently failing test.
The tests and the production code are written together, with the tests just a few seconds ahead of the production code.