Search code examples
javaapipact

Why should we have 1 Pact file for EVERY consumer if all consumers use same API in same way?


I am trying to introduce Pact framework in our company, and one of the concerns raised was below:

Scenario : This xyz API is called by 40 consumers, every consumer needs the same functionalities currently. So why should we maintain 40 Pact Files as opposed to just maintaining a single file?

Is there any better approach than to have ONE pact file for EACH consumer, considering the pact file maintainence?


Solution

  • If you have 40 consumers using exactly the same functionalities, there wouldn't be an issue with using a single pact file for all those interactions.

    However, I find this extremely hard to believe that this is your case and as far as I've seen it in reality, never actually happens. Your provider might have all this functionality, but each consumer doesn't have to test for that functionality unless your consumer actually uses it. Furthermore, each consumer might have a different way to call/access this functionality with different type of data, headers or URL, which makes it unique and needed to test the provider fully for all potential edge cases.

    Also, unless the consumer updates to use this new functionality, there's no reason to update the pact file. The point is to try to create independent files for each consumer-provider interaction; this does however increase maintenance when you have multiple consumers to a provider.

    We will take your feedback and see what we can do for the future of the product to make this maintenance easier to do or minimize the impact.