知识卡片
消费者契约与模式测试
消费者驱动契约记录消费方需要的具体请求、前置状态与预期响应。消费方通过模拟提供方检查自己的行为,提供方独立重放示例以验证实现,因此不必为每次改动部署全部服务。这适合消费者数量有限且团队能讨论契约的内部集成。
模式测试从提供方发布的 OpenAPI 出发,检查发出的消息是否符合声明的类型、范围和格式。它适合发布给大量未知消费者的 API,能核对公开的形状约定。若关键内部消费方还依赖某一具体交互,可在模式测试之外补消费方契约。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 用模式测试检查 API 遵约 7.7 How schema tests differ from consumer-driven contract tests · 查看原书依据
Consumer-driven contract testing is a different approach to integration testing. It involves testing a service in isolation against a consumer contract—a document that defines the message conversations it expects the provider to support. That is, it’s a way of ensuring that two services have a shared understanding of how to communicate with each other. It does this by checking each of them in isolation using concrete messages (specification examples).
参考来源
- 位置:《Automating API Delivery APIOps with OpenAPI》《第 07 章 用模式测试检查 API 遵约》(7.7 How schema tests differ from consumer-driven contract tests;来源项目 book-source,extracted/Automating API Delivery APIOps with OpenAPI/_epub-src/OEBPS/Text/chapter-7.xhtml#p117)
- 结论依据:说明消费者驱动契约如何用具体交互分别验证消费方和提供方。
- 原始内容:Consumer-driven contract testing is a different approach to integration testing. It involves testing a service in isolation against a consumer contract—a document that defines the message conversations it expects the provider to support. That is, it’s a way of ensuring that two services have a shared understanding of how to communicate with each other. It does this by checking each of them in isolation using concrete messages (specification examples).