Test-driven development is a software development process relying on software requirements being converted to test cases before software is fully developed, and tracking all software development by repeatedly testing the software against all test cases. Wikipedia
Follow the Three Laws of TDD:
- You must write a failing test before you write any production code.
- You must not write more of a test than is sufficient to fail, or fail to compile.
- You must not write more production code than is sufficient to make the currently failing test pass.
How to do this practically? Do you know about Red-Green-Refactor? Apply in shifted order and repeat:
- Green: Fix a failing unit test
- Refactor: Tidy up the code
- Red: Create a unit tests that fails.
Then have someone else do the steps above. And so on ...