知识卡片
测试接口只为必要状态准备
无法通过公开业务操作构造测试状态时,可提供限于测试环境的专用接口。它必须控制暴露和数量;若隐藏测试操作远多于业务操作,应重审服务设计。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
原书出处
参考来源
- 位置:《Principles of Software Architecture Modernization》第7章《Proper Service Testing》(源文件:`_epub-src/OPS/ch07.xhtml`,归一化正文 [67089:71341))
- 结论依据:原文指出测试接口可准备难以诱导的状态,也会增加契约与误用风险。
- 原始内容:Testing interfaces is a powerful technique, but it is not a silver bullet. You don’t want to end up with services with one valid method and 79 hidden methods to manipulate state. In that case, you might need to rethink your software design or testing strategy. Regardless, it is a powerful tool in your testing toolbox. Test data setup Simple idea: have scripts that create all test data needed - near the source.