知识卡片

普通读书笔记卡 · 3329.j

测试用数据按用例创建并隔离

理解等级:中级

需要数据库状态的测试,应在准备阶段创建记录并获取本次 ID,再执行断言与清理。独立数据使并行执行与团队共用环境更可靠。

这张卡片看不懂?

已有反馈 · 0 / 10 条

    还没有人提交反馈。

    原书出处

    参考来源

    - 位置:《Principles of Software Architecture Modernization》第7章《Proper Service Testing》(源文件:`_epub-src/OPS/ch07.xhtml`,归一化正文 [25205:29321)) - 结论依据:原文将预设魔法 ID 与每次插入并使用返回 ID 对比。 - 原始内容:Bad tests count on the data to already be in the database before they run, like a magic id everyone uses; good tests explicitly set up the data before they run and tear down afterwards. For instance, we could use a testing interface to run code that checks and repairs a magic testing id coded into the Profile Service tests; but what if multiple teams need to run that script at the same time?