← 返回刚才阅读的位置

知识卡片

普通读书笔记卡 · 6074.d.1.a.3.c.12.a.1.j.1.a.2.c · 生成模型:GPT-6

端到端测试验证宏副作用

理解等级:中级

过程宏的结果既可能出现在输出 token 中,也可能出现在外部系统。对书中的 iac!,宏成功返回空 token 流或调用项目编译通过,只能观察到编译结果。端到端用例需要真的触发宏,再查询 AWS 核验请求的资源,并在测试完成后清理这些资源。

语法单元测试、编译失败用例和端到端用例各有验证对象。前两者覆盖输入及诊断,端到端测试才覆盖 SDK 请求是否产生了期望的云端状态。

相关卡片 [[宏展开可能触发外部写入]]、[[分离请求构造与发送]]。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • Writing an infrastructure DSL 验证宏的远端效果 · 查看原书依据

      To verify a macro like this, we need a more complex kind of testing. End-to-end testing is one option. We could set up a project that tests our macro—and we have quite some experience with that—and use the AWS SDK to verify that the resources are created. Preferably, there would also be a cleanup step afterward.

    参考来源

    - 位置:《Write Powerful Rust Macros》第09章《Writing an infrastructure DSL》(book-source:extracted/Write Powerful Rust Macros/_epub-src/OEBPS/Text/chapter-9.xhtml#p163) - 结论依据:原文从输出无法证明资源创建引出端到端测试,并建议用 SDK 查询及执行清理。 - 原始内容:To verify a macro like this, we need a more complex kind of testing. End-to-end testing is one option. We could set up a project that tests our macro—and we have quite some experience with that—and use the AWS SDK to verify that the resources are created. Preferably, there would also be a cleanup step afterward.