知识卡片
端到端测试验证宏副作用
过程宏的结果既可能出现在输出 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.