Let’s Summarize #



  • write a test
  • make the compiler pass
  • run test, see that it fails and check the error message is meaningful
  • write enough code to make the test pass
  • refactor


  • write a failing test and see it fail so we know we have written a relevant test for our requirements and seen that it produces an easy to understand description of the failure
  • writing the smallest amount of code to make it pass so we know we have working software
  • then refactor, backed with the safety of our tests to ensure we have well-crafted code that is easy to work with

red、green、refactor: throughout this book, we have emphasised the tdd process of:

  • red: write a test & watch it fail
  • green: write the minimal amount of code to make it work
  • and then refactor

Source Analysis #

References #

  1. https://github.com/quii/learn-go-with-tests