Episode 19 – Advanced TDD

Clean Code

Episode 19

This episode is a two parts serie on a deep dive into the test-drive development.

  • TDD Review of the Three Laws
    • Before production code, must write unit test to fail
    • Stop writing the test as soon as you got a failure
    • Don’t write more production code than you need to pass the test
    • Red Green Refactor
  • The Single Assert Rule
    • Every unit test should only have one assert
    • Arrange-Act-Assert
    • Every action should have one assert.
  • Incremental Algorithmic
    • As the test gets more specific, the code gets more generic.
  • Getting Stuck
    • Should create degenerate test case first. Approach from outside in.
  • Getting Unstuck
    • First, make most degenerate test case.
    • Solve the problem using test case with incremental complexity
    • For every failed test, we make it pass by generalize the production code
    • Don’t make specific with the code
  • Conclusion
    • Test can only prove the program wrong and never prove the program right
  • References