【问题标题】:Does pact support application/JavaScript content-type?协议是否支持应用程序/JavaScript 内容类型?
【发布时间】:2018-06-01 08:13:14
【问题描述】:

我的微服务与之交互的第三方服务返回内容类型为 application/JavaScript;charset=UTF-8 的响应。因此,pact json 的响应正文为字符串,匹配规则的正文为空。

使用以下契约依赖:

testIntegrationCompile('au.com.dius:pact-jvm-consumer-junit_2.12:3.5.11')
   testIntegrationCompile('au.com.dius:pact-jvm-provider-junit_2.12:3.5.11')
   testIntegrationCompile('au.com.dius:pact-jvm-provider-spring_2.12:3.5.11')
   testIntegrationCompile('au.com.dius:pact-jvm-consumer-java8_2.12:3.5.11')

【问题讨论】:

    标签: spring testing integration-testing microservices pact


    【解决方案1】:

    首先,不,Pact 不支持 javascript 代码。正如您所注意到的,它只会将正文视为字符串。你仍然可以用字符串体做契约测试,但它们会很脆弱,因为一个字符的差异会导致匹配失败。

    其次,如果存在 javascript 匹配器,您会期望什么行为?

    第三,Pact 不是测试第三方 API 的好工具。它是专门为消费者驱动的合约测试而编写的,而不是一般的 API 模拟。请在此处阅读文档:https://docs.pact.io/getting-started/what-is-pact-good-for

    【讨论】:

      猜你喜欢
      • 2011-08-14
      • 1970-01-01
      • 2018-09-05
      • 1970-01-01
      • 2021-01-25
      • 2022-01-02
      • 2012-07-09
      • 2014-11-08
      • 1970-01-01
      相关资源
      最近更新 更多