知识卡片
测试关注契约而非内部实现
通过输入和可见结果验证责任,可以容许内部合理重构。仅断言返回某类或某私有函数被调用,可能让核心逻辑被绕开仍通过;结构约束只有自身属于要求时才适合直接断言。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
- · 软件自动化测试
原书出处 · 1 处
- · 查看原书依据
Tests should check behavior, not implementation Let’s illustrate this point with Jason Swett’s analogy of testing a car. When you test implementation, you try to test that the car works by checking if it has all the right stuff: presence of an engine, an ignition, wheels, and everything else that’s needed to get from point A to point B. On the other hand, when you
参考来源
- 位置:《Effective Machine Learning Teams (David Tan, Ada Leung, David Colls)》第05章《软件自动化测试》(来源项目:a19c7933-4eda-4176-aebd-30fe7e1ad292;源文件:extracted/Effective Machine Learning Teams (David Tan, Ada Leung, David Colls)/_epub-src/OEBPS/ch05.html)
- 结论依据:摘录中关于测试关注契约而非内部实现的定义、比较或条件支撑卡片;原书表述不严谨的范围已在覆盖记录逐项限定,不把案例结果外推为普遍结论。
- 原始内容:Tests should check behavior, not implementation Let’s illustrate this point with Jason Swett’s analogy of testing a car. When you test implementation, you try to test that the car works by checking if it has all the right stuff: presence of an engine, an ignition, wheels, and everything else that’s needed to get from point A to point B. On the other hand, when you