知识卡片
OpenAPI模式测试检查什么
OpenAPI 模式测试向提供方发送请求,并把实际响应与相同操作、状态码和媒体类型下的模式比较。例如商品响应必须包含 UUID 字符串 id,出现 name 时要满足声明的长度,关闭额外属性时出现未声明字段将失败。也可检查操作是否返回声明的状态码、响应头和媒体类型。
模式断言负责消息结构和格式。业务测试另检查值是否满足真实规则、操作有没有产生正确副作用,性能测试另看时延和容量。契约漏写约束时,结构验证只能确认已经声明的部分。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 用模式测试检查 API 遵约 7.1 Schema tests · 查看原书依据
A schema test for the preceding message checks that the actual message returned from the API operation conforms to the schema. This is an automated test that compares the response of the API with the schema in the API definition and fails if they don’t match. For example, for the preceding schema, a schema test checks that the name property is of type string and has a length not less than 1 or greater than 50.
参考来源
- 位置:《Automating API Delivery APIOps with OpenAPI》《第 07 章 用模式测试检查 API 遵约》(7.1 Schema tests;来源项目 book-source,extracted/Automating API Delivery APIOps with OpenAPI/_epub-src/OEBPS/Text/chapter-7.xhtml#p14)
- 结论依据:说明实际响应的字段、边界、内容类型和头可按模式断言。
- 原始内容:A schema test for the preceding message checks that the actual message returned from the API operation conforms to the schema. This is an automated test that compares the response of the API with the schema in the API definition and fails if they don’t match. For example, for the preceding schema, a schema test checks that the name property is of type string and has a length not less than 1 or greater than 50.