Test-driven Development Cycle

  1. Write tests first
  2. Run all tests, the new tests should fail for expected reasons
  3. Write the simplest code that passes the new test (All tests should pass now)
  4. Refactor as needed, using tests after each refactor to ensure that functionality is preserved
  5. Repeat
  • TDD is primarily a developer’s tool to help create well-written unit of code (function, class, or module) that correctly performs a set of operations.

See also: