unit-testing-4-导言-好单元测试的四大支柱
zeroChapter 4 The four pillars of a good unit test
第 4 章 好单元测试的四大支柱
仅个人学习使用,支持正版。
书名:Unit Testing: Principles, Practices, and Patterns
Now we are getting to the heart of the matter. In chapter 1, you saw the properties of a good unit test suite:
现在我们进入本书的核心。在第 1 章中,你已经看到了一个优秀单元测试套件应具备的属性:
- It is integrated into the development cycle. You only get value from tests that you actively use; there’s no point in writing them otherwise.
它被集成进开发周期。只有那些你会主动使用的测试才有价值;否则写测试就没有意义。 - It targets only the most important parts of your code base. Not all production code deserves equal attention. It’s important to differentiate the heart of the application (its domain model) from everything else. This topic is tackled in chapter 7.
它只针对代码库中最重要的部分。并不是所有生产代码都值得同等关注。区分应用程序的核心,也就是领域模型,与其他部分非常重要。第 7 章会讨论这个主题。 - It provides maximum value with minimum maintenance costs. To achieve this last attribute, you need to be able to
它以最低维护成本提供最大价值。要实现这个属性,你需要能够:- Recognize a valuable test (and, by extension, a test of low value)
识别有价值的测试,并进一步识别低价值的测试。 - Write a valuable test
写出有价值的测试。
- Recognize a valuable test (and, by extension, a test of low value)
This chapter covers:
本章内容包括:
- Exploring dichotomies between aspects of a good unit test
探索优秀单元测试各个方面之间的两难取舍。 - Defining an ideal test
定义理想测试。 - Understanding the Test Pyramid
理解测试金字塔。 - Using black-box and white-box testing
使用黑盒测试与白盒测试。