知识卡片
可测试性不应牺牲服务边界
如果测试需要观察内部状态,先考虑改变测试层级、构造状态或限定可见性;不能为方便测试把不该公开的实现细节放进业务契约。服务设计的长期独立性优先于单项测试的便利。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
原书出处
参考来源
- 位置:《Principles of Software Architecture Modernization》第7章《Proper Service Testing》(源文件:`_epub-src/OPS/ch07.xhtml`,归一化正文 [21093:25205))
- 结论依据:原文讨论契约、包可见性、反射和改用其他测试技术后,明确要求保留正确的软件设计。
- 原始内容:If you need to choose between software testability and the right software design, always pick the right design. Sometimes you will find a way to expose something on the contract and also improve testing without coupling to the internal implementation. That’s a great outcome and a win-win for all.