35. TDD的⼏个准则
• Write only enough of a unit test to fail.
• Write only enough production code to make the failing unit test
pass.
• 测试失败 => 写业务代码
• 测试通过 => 写测试代码
37. 浪费时间?
• debug修bug,跟其他⼈解释代码的时间 -> 写测试的时间
• 减少返⼯,减少上下⽂切换的次数
The results of the case studies indicated that the pre-release
defect density of the four products decreased between 40% and
90% relative to similar projects that did not use the TDD
practice. Subjectively, the teams experienced a 15–35%
increase in initial development time after adopting TDD.
⼀份来⾃微软的报告
44. 参考
【书籍】Refactoring: Improving the Design of Existing Code (2nd Edition) by Martin Fowler
【书籍】Clean Code: A Handbook of Agile Software Craftsmanship by Robert C. Martin
【⽂章】 An Overview of JavaScript Testing in 2019 ( https://medium.com/welldone-software/
an-overview-of-javascript-testing-in-2019-264e19514d0a )
【课程】JavaScript Testing Practices and Principles by Kent C. Dodds ( https://
frontendmasters.com/courses/testing-practices-principles/ )