Search code examples
karate

Please advise on what functionality in Karate framwork performs similar roles of Pact broker in contract testing


I am new to contract testing and trying to do a PoC using Karate framework. I know Pact (another contract testing tool) used for contract testing where in contracts and verification results between consumer and provider projects are managed using Pact broker.

When it comes to Karate, please advise on what functionality in Karate framwork performs similar roles of Pact broker(managing contracts and verification results).

Appreciating your help on this.


Solution

  • Karate does not have the equivalent of the broker. It is possible to achieve contract testing without a broker if the Producer and Consumer have access to the mock and test. Git is typically the best way to share these artifacts. Since they are plain-text files, even email would suffice.

    So you don't need to stand up a server and go through all the complications of keeping it running and accessible by both teams and worry about the security implications of if the Producer or Consumer is outside your firewall.

    Note that if you genuinely have a case where the Producer or Consumer is not part of your corporate organization, you have a bigger problem to solve - which is to get that team to agree to follow the Consumer Driven Contract flow.

    But if you are trying to do CDC where the producer and consumer are 2 teams within the same organization, Karate is more than sufficient. You just need a Git repo. The mock becomes a "deliverable" for the Producer team. The only thing you may miss is the visualization of "which teams depend on which service", which IMHO is not a big deal, it is just a pretty picture you can do without. The advantage of Karate is all the complex assertions that you can achieve and that you can continue to write normal tests, as long as the mock is "smart" enough to reply to those tests.

    Skip to 33:30 of this video for an explanation: https://youtu.be/yu3uupBZyxc?t=2013

    And read this article for a detailed explanation of what you should expect from a Contract Testing tool: https://www.linkedin.com/pulse/api-contract-testing-visual-guide-peter-thomas/