知识卡片
Rocket 路由宏测试
Rocket 是 Rust Web 框架。其 #[get("/hello/<name>")] 之类的属性把函数声明变成带路径参数的路由入口。这样的宏既生成 API 也定义调用规则,所以可以从使用方验证有效声明,用编译失败用例验证不合法的声明,再配合性能基准和模糊测试覆盖其他风险。这里记录书中观察到的项目测试组织。
相关卡片 [[按行为风险分配宏测试]]。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- Testing a builder macro 真实项目的用例布局 · 查看原书依据
The first, Rocket, is one we have encountered before in the introduction as well as in chapter 3. It is a web framework for Rust that uses macros to generate HTTP endpoints. For example, adding the macro #[get("/hello/<name>")] to a function will make it the entry point to a URL with path /hello and will pass on a path parameter called “name.” Rocket’s unit tests are black-box and located in the tests folder of the project.
参考来源
- 位置:《Write Powerful Rust Macros》第06章《Testing a builder macro》(book-source:extracted/Write Powerful Rust Macros/_epub-src/OEBPS/Text/chapter-6.xhtml#p170)
- 结论依据:6.7 用路由属性说明 Rocket 的程序化接口,并指出其测试中同时存在公开调用、编译失败、基准测试和模糊测试。
- 原始内容:The first, Rocket, is one we have encountered before in the introduction as well as in chapter 3. It is a web framework for Rust that uses macros to generate HTTP endpoints. For example, adding the macro #[get("/hello/<name>")] to a function will make it the entry point to a URL with path /hello and will pass on a path parameter called “name.” Rocket’s unit tests are black-box and located in the tests folder of the project.