← 返回刚才阅读的位置

知识卡片

普通读书笔记卡 · 3282.a

松耦合接口易于替身测试

理解等级:中级

消费方做集成测试时,松耦合 API 可把真实提供方换成返回约定响应的桩或虚拟服务。若接口绑定了提供方内部实现,测试往往必须启动真实服务,测试环境和执行成本随之增加。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • · 查看原书依据

      An API designed with loose coupling in mind will typically be much easier to mock or virtualize when performing integration and end-to-end testing. A loosely coupled API enables the provider implementation to be easily swapped. When testing a consumer, the provider API implementation can be swapped for a simple stub or virtual service that returns the required response.

    参考来源

    - 位置:《Mastering API Architecture》第8章《Redesigning Applications to API-Driven Architectures》之《Loose Coupling Enables Easier Mocking and Virtualizing When Testing!》(源文件:_epub-src/OEBPS/ch08.xhtml) - 结论依据:原文直接比较可替换的桩服务与高度耦合接口需运行提供方的测试方式。 - 原始内容:An API designed with loose coupling in mind will typically be much easier to mock or virtualize when performing integration and end-to-end testing. A loosely coupled API enables the provider implementation to be easily swapped. When testing a consumer, the provider API implementation can be swapped for a simple stub or virtual service that returns the required response.