《Unit Testing: Principles, Practices, and Patterns》 学习
zero仅个人学习使用,支持正版。 《Unit Testing: Principles, Practices, and Patterns》
Part 1: The bigger picture | 全局视角
Chapter 1: The goal of unit testing | 单元测试的目标
- 1.1 The current state of unit testing | 单元测试的现状
- 1.2 The goal of unit testing | 单元测试的目标
- 1.3 Using coverage metrics to measure test suite quality | 使用覆盖率指标衡量测试套件质量
- 1.4 What makes a successful test suite? | 什么样的测试套件才算成功?
- 1.5 What you will learn in this book | 你将从本书学到什么
- 1.6 Summary | 总结
Chapter 2: What is a unit test? | 什么是单元测试?
- 2.1 The definition of “unit test” | “单元测试”的定义
- 2.2 The classical and London schools of unit testing | 单元测试的经典学派与伦敦学派
- 2.3 Contrasting the classical and London schools | 对比经典学派与伦敦学派
- 2.4 Integration tests in the two schools | 两个学派中的集成测试
- 2.5 Summary | 总结
Chapter 3: The anatomy of a unit test | 单元测试的结构
- 3.1 How to structure a unit test | 如何组织一个单元测试
- 3.2 Exploring the xUnit testing framework | 探索 xUnit 测试框架
- 3.3 Reusing test fixtures between tests | 在测试之间复用测试夹具
- 3.4 Naming a unit test | 单元测试如何命名
- 3.5 Refactoring to parameterized tests | 重构为参数化测试
- 3.6 Using an assertion library to further improve test readability | 使用断言库进一步提升测试可读性
- Summary | 总结
Part 2: Making your tests work for you | 让测试为你服务
Chapter 4: The four pillars of a good unit test | 好单元测试的四大支柱
- 4.1 Diving into the four pillars of a good unit test | 深入理解优秀单元测试的四大支柱
- 4.2 The intrinsic connection between the first two attributes | 前两个属性之间的内在联系
- 4.3 The third and fourth pillars: Fast feedback and maintainability | 第三和第四大支柱:快速反馈与可维护性
- 4.4 In search of an ideal test | 寻找理想测试
- 4.5 Exploring well-known test automation concepts | 探索常见的测试自动化概念
- 4.6 Summary | 总结
Chapter 5: Mocks and test fragility | Mock 与测试脆弱性
- 5.1 Differentiating mocks from stubs | 区分 mock 和 stub
- 5.2 Observable behavior vs. implementation details | 可观察行为 vs. 实现细节
- 5.3 The relationship between mocks and test fragility | mock 与测试脆弱性之间的关系
- 5.4 The classical vs. London schools of unit testing, revisited | 重新审视经典学派与伦敦学派
- 5.5 Summary | 总结
Chapter 6: Styles of unit testing | 单元测试的风格
- 6.1 The three styles of unit testing | 三种单元测试风格
- 6.2 Comparing the three styles of unit testing | 比较三种单元测试风格
- 6.3 Understanding functional architecture | 理解函数式架构
- 6.4 Transitioning to functional architecture and output-based testing | 迈向函数式架构和基于输出的测试
- 6.5 Understanding the drawbacks of functional architecture | 理解函数式架构的缺点
- Summary | 总结
Chapter 7: Refactoring toward valuable unit tests | 重构为有价值的单元测试
- 7.1 Identifying the code to refactor | 识别需要重构的代码
- 7.2 Refactoring toward valuable unit tests | 重构为有价值的单元测试
- 7.3 Analysis of optimal unit test coverage | 最佳单元测试覆盖率分析
- 7.4 Handling conditional logic in controllers | 处理控制器中的条件逻辑
- 7.5 Conclusion | 结论
- 7.6 Summary | 总结
Part 3: Integration testing | 集成测试
Chapter 8: Why integration testing? | 为什么需要集成测试?
- 8.1 What is an integration test? | 什么是集成测试?
- 8.2 Which out-of-process dependencies to test directly | 哪些进程外依赖应该直接测试?
- 8.3 Integration testing: An example | 集成测试:一个示例
- 8.4 Using interfaces to abstract dependencies | 使用接口抽象依赖
- 8.5 Integration testing best practices | 集成测试最佳实践
- 8.6 How to test logging functionality | 如何测试日志功能
- 8.7 Conclusion | 结论
Chapter 9: Mocking best practices | Mock 最佳实践
- 9.1 Maximizing mocks’ value | 最大化 mock 的价值
- 9.2 Mocking best practices | Mock 最佳实践
Chapter 10: Testing the database | 测试数据库
- 10.1 Prerequisites for testing the database | 测试数据库的前提条件
- 10.2 Database transaction management | 数据库事务管理
- 10.3 Test data life cycle | 测试数据生命周期
- 10.4 Reusing code in test sections | 在测试各阶段复用代码
- 10.5 Common database testing questions | 常见数据库测试问题
- 10.6 Conclusion | 结论
Part 4: Unit testing anti-patterns | 单元测试反模式
Chapter 11: Unit testing anti-patterns | 单元测试反模式
- 11.1 Unit testing private methods | 测试私有方法
- 11.2 Exposing private state | 暴露私有状态
- 11.3 Leaking domain knowledge to tests | 向测试泄露领域知识
- 11.4 Code pollution | 代码污染
- 11.5 Mocking concrete classes | Mock 具体类
- 11.6 Working with time | 处理时间
- 11.7 Conclusion | 结论