知识卡片

普通读书笔记卡 · 3329.h

好测试对实现重构保持韧性

理解等级:中级

测试应主要验证稳定契约和可观察行为,使内部重构不需连带修改大量断言。过度模拟内部步骤、依赖日志文字或完整异常消息会提高测试与实现的耦合。

这张卡片看不懂?

已有反馈 · 0 / 10 条

    还没有人提交反馈。

    原书出处

    参考来源

    - 位置:《Principles of Software Architecture Modernization》第7章《Proper Service Testing》(源文件:`_epub-src/OPS/ch07.xhtml`,归一化正文 [16893:21093)) - 结论依据:原文以复杂 mock、内部细节和错误断言机制说明重构脆弱性。 - 原始内容:Refactoring resiliency As an engineer, you want to be able to refactor code without breaking all your tests all the time. Otherwise, tests get in the way. Engineers will differentiate between when a test breaks because of some downstream dependency or a code change introduces a bug, vs. when the test is too sensitive to the implementation. The latter is a problem with the test, not the business code, the infamous “bug in the test” scenario.