Test Driven Development - Best practices

Here are my practice when apply TDD, your idea is welcome:

  • Write the simple test first, then write code. After that write test code for more complexity functionality
  • Keep test code as simple as possible
  • Run test immediately whenever complete writing code
  • If spending much time for writing code, break the functionality into smaller ones and applying TDD for these pieces
  • Whenever test code or productive code smells, refactor it immediately
  • After writing code, use coverage tool to make sure productive code is covered 100% by test method. If some piece of code is not covered, your implementation has issue!
  • Use mock objects if needed
  • Automate unit test and intergrate them into CI server