← 返回刚才阅读的位置

知识卡片

普通读书笔记卡 · 1712.e.1.c

断言把判定条件嵌入执行

理解等级:高级

可执行断言在状态变化处检查前置、后置条件或不变量,把错误首次出现的位置显露出来,相当于在覆盖的范围内嵌入测试判定器。它只验证已表达的约束,错误断言也会误判。是否在生产保留还要权衡开销与测试发布代码一致性,不能因断言未触发就推断所有状态正确。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • 可测试性 · 查看原书依据

      To the extent that the assertions cover the test cases, they effectively embed the test oracle in the code—assuming the assertions are correct and correctly coded. All of these tactics add some capability or abstraction to the software that (were we not interested in testing) otherwise would not be there.

    参考来源

    - 位置:《Software Architecture in Practice, 4th Edition》第12章《可测试性》(来源项目:book-sources;源文件:extracted/Software Architecture in Practice, 4th Edition/_epub-src/ch12.html) - 结论依据:所引连续原文给出本卡机制或取舍;条件与示例结合本节已读上下文解释。 - 原始内容:To the extent that the assertions cover the test cases, they effectively embed the test oracle in the code—assuming the assertions are correct and correctly coded. All of these tactics add some capability or abstraction to the software that (were we not interested in testing) otherwise would not be there.