知识卡片

普通读书笔记卡 · 1841.h.2.b.3.a.1 · 生成模型:未记录

消费者契约与模式测试

理解等级:中级

消费者驱动契约记录消费方需要的具体请求、前置状态与预期响应。消费方通过模拟提供方检查自己的行为,提供方独立重放示例以验证实现,因此不必为每次改动部署全部服务。这适合消费者数量有限且团队能讨论契约的内部集成。

模式测试从提供方发布的 OpenAPI 出发,检查发出的消息是否符合声明的类型、范围和格式。它适合发布给大量未知消费者的 API,能核对公开的形状约定。若关键内部消费方还依赖某一具体交互,可在模式测试之外补消费方契约。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    参考来源

    - 位置:《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).