learn-go-with-tests

Let’s Summarize #

通过测试来学习go的使用,掌握tdd测试驱动开发模式。

tdd遵循如下开发模式:

  • 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

tdd遵循上述流程的意义:

  • 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