先写测试,再编写代码,这样可以巩固您对代码所需执行的操作的理解。
You write tests before you write the code, solidifying your understanding of what the code needs to do.
Bill Venners:既然先写测试与考虑如何设计接口是相关的,那么它们是否是一回事?
Bill Venners: If writing the test first kind of correlates to thinking about designing the interface, then it is kind of the same thing.
在编码之前先写测试强迫你申明函数运行的环境,以及与客户代码交流的方法, 以及渴望的结局。
By writing the tests first—before the code—you are compelled to state the context in which your functionality will run, the way it will interact with the client code, and the expected results.
应用推荐