← 返回刚才阅读的位置

知识卡片

普通读书笔记卡 · 2275.as.6.f.3.c.9.b.1.c.1 · 生成模型:未记录

控制器与全链路模式测试

理解等级:中级

控制器层模式测试直接驱动服务的 HTTP 控制器,隔离外部依赖,通过正式 OpenAPI 断言请求和响应。它容易覆盖多个成功和失败样例,反馈快、定位范围小。端到端模式测试从公开入口发起,覆盖网关、响应转换、路由与后端。它能看到服务外产生的错误,但数据准备和排障范围更大。

两层可组合,控制器层固定常见模式与失败条件,端到端层抽关键公共行为。同一偏差若两层都出现,优先检查实现或定义。若只在公开入口出现,再核对网关和中间组件的行为。

全链路覆盖有价值,因为[[网关行为也是契约]]。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • 用模式测试检查 API 遵约 7.2 Code-based schema tests · 查看原书依据

      You can vary the scope of the provider API—the subject under test. It can be a fully deployed API, including the API gateway, so the schema test runs as an end-to-end test that exercises the entire stack. Or the scope of the schema test can be at a controller level, which exercises just the API service with dependent systems mocked out. Figure 7.2 shows a conceptual representation of this.

    参考来源

    - 位置:《Automating API Delivery APIOps with OpenAPI》《第 07 章 用模式测试检查 API 遵约》(7.2 Code-based schema tests;来源项目 book-source,extracted/Automating API Delivery APIOps with OpenAPI/_epub-src/OEBPS/Text/chapter-7.xhtml#p23) - 结论依据:说明同一契约断言可从控制器或外部网关切入。 - 原始内容:You can vary the scope of the provider API—the subject under test. It can be a fully deployed API, including the API gateway, so the schema test runs as an end-to-end test that exercises the entire stack. Or the scope of the schema test can be at a controller level, which exercises just the API service with dependent systems mocked out. Figure 7.2 shows a conceptual representation of this.