知识卡片

普通读书笔记卡 · 6075.d.2.a · 生成模型:未记录

先看测试为何失败

理解等级:中级

先以测试描述新增行为,再写能编译的最小骨架。确认测试因行为尚未实现而失败,再写足量代码使其通过,重构后重复运行。在 minigrep 中,骨架返回空列表,清楚暴露缺少命中行。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    参考来源

    - 位置:《The Rust Programming Language(第2版)》第12章 I/O 项目:构建命令行程序(来源项目 a19c7933-4eda-4176-aebd-30fe7e1ad292,`extracted/The Rust Programming Language(第2版)/_epub-src/c12.xhtml`,块 0191) - 结论依据:暂时返回空向量使缺失 API 的编译错误变成可核对的行为断言失败。 - 原始内容:We aren’t yet able to run this test and watch it fail because the test doesn’t even compile: the search function doesn’t exist yet! In accordance with TDD principles, we’ll add just enough code to get the test to compile and run by adding a definition of the search function that always returns an empty vector, as shown in Listing 12-16.