知识卡片
集成测试分层验证
微服务集成可分层验证:服务端对照 API 规范测试实现,客户端用按规范生成的模拟响应测试调用逻辑,最后让真实服务相互调用做端到端测试。前两层能较快发现契约偏差,却不能代替真实服务组合下的行为验证。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
原书出处
参考来源
- 位置:《Microservice APIs》第 1 章《What are microservice APIs?》(源文件:_epub-src/OEBPS/Text/01.htm)
- 结论依据:1.3.2 节先说明跨多个服务的集成测试比单进程更困难,再分别要求服务端按规范、客户端按文档模拟响应,以及真实微服务端到端运行。
- 原始内容:You can test the API implementation against the API specification using tools like Dredd and Schemathesis, as you’ll learn in chapter 12. ... You can write unit tests for the API client using the API documentation to generate mocked responses from the service. ... Finally, none of these tests will be sufficient without a full-blown end-to-end test that runs the actual microservices making calls to each other.