知识卡片
用最小样例锁定诊断
规则测试只启用被测规则。用最小 OpenAPI 片段覆盖合规和不合规输入,断言无诊断或匹配预期消息、路径和级别。先写失败用例,再实现函数;日后升级时同一用例可以检验规则行为有无无意变化。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 自定义 Lint 与安全检查 10.1 The need for custom functions · 查看原书依据
All the usual rules of writing unit tests apply here. Your test should make clear what is the subject under test (SUT)—that is, the ruleset you’re testing. It should invoke the operation you’re testing (i.e., the name of your new rule) with the data it’s testing against—an example API definition against which the rule should either pass or report problems
参考来源
- 位置:《Automating API Delivery APIOps with OpenAPI》《第 10 章 自定义 Lint 与安全检查》(10.1 The need for custom functions;来源项目 book-source,extracted/Automating API Delivery APIOps with OpenAPI/_epub-src/OEBPS/Text/chapter-10.xhtml#p25)
- 结论依据:原文规定单规则隔离、最小输入与诊断断言。
- 原始内容:All the usual rules of writing unit tests apply here. Your test should make clear what is the subject under test (SUT)—that is, the ruleset you’re testing. It should invoke the operation you’re testing (i.e., the name of your new rule) with the data it’s testing against—an example API definition against which the rule should either pass or report problems