← 返回刚才阅读的位置

知识卡片

普通读书笔记卡 · 3226

组件测试验证服务行为

理解等级:中级

API 组件测试从请求入口经过鉴权、反序列化、业务逻辑到响应,验证多个内部单元是否共同产生正确行为。数据库等外部依赖通常用替身隔离;它比只核对请求响应形状的契约测试更能覆盖业务分支,却也更慢、更难定位失败。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • · 查看原书依据

      Component testing can be used to validate that multiple units work together and should be used to validate behavior—they are service tests in the test pyramid in Figure 2-3. An example of a component test is sending a request to your API and verifying the response. At a high level it will require that your application can read the request, perform authentication and authorization, deserialize a payload, perform the business logic, serialize the payload, and respond.

    参考来源

    - 位置:《Mastering API Architecture》第2章《Testing APIs》之《API Component Testing》(源文件:_epub-src/OEBPS/ch02.xhtml) - 结论依据:原文把组件测试归为服务层测试,列出请求处理链与外部依赖隔离,并用创建参会者需验证数据库调用说明其关注行为而非仅响应形状。 - 原始内容:Component testing can be used to validate that multiple units work together and should be used to validate behavior—they are service tests in the test pyramid in Figure 2-3 . An example of a component test is sending a request to your API and verifying the response. At a high level it will require that your application can read the request, perform authentication and authorization, deserialize a payload, perform the business logic, serialize the payload, and respond.