知识卡片

普通读书笔记卡 · 743.d.2.b.5.a.2.a.2 · 生成模型:GPT-6

测试驱动开发的红绿循环

理解等级:初级

测试驱动开发以可观察的需求开始。先写一个测试,并观察它因缺少预期行为而失败。补上足够的实现使测试通过,再用下一个用例推进。书中示例先只支持空结构体,再引入一个字段、混合类型和非 Copy 字段。每次成功只说明相应场景可用,支持范围随用例逐步扩张。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • Testing a builder macro 构建器任务与测试驱动 · 查看原书依据

      NOTE Test-driven development (TDD) is a way of coding that puts tests in the center of things. Rather than testing being an afterthought, every piece of code that we write is preceded by a test verifying the behavior we would like to see. The test starts out red (failing) because there is no implementation yet. After we write code and the test turns green (succeeds), we write another test for the next bit of behavior.

    参考来源

    - 位置:《Write Powerful Rust Macros》第06章《Testing a builder macro》(book-source:extracted/Write Powerful Rust Macros/_epub-src/OEBPS/Text/chapter-6.xhtml#p9) - 结论依据:开篇注释用新增测试先失败、补实现后通过再进入下一轮的顺序界定 TDD,后续单字段和混合字段示例展示小步补行为的方式。 - 原始内容:NOTE Test-driven development (TDD) is a way of coding that puts tests in the center of things. Rather than testing being an afterthought, every piece of code that we write is preceded by a test verifying the behavior we would like to see. The test starts out red (failing) because there is no implementation yet. After we write code and the test turns green (succeeds), we write another test for the next bit of behavior.