Hello Team, I have a generic question w.r.t pact c...
# general
p
Hello Team, I have a generic question w.r.t pact consumer. Does pact support letting the consumer to generate the pact json file by hitting the real provider service instead of hitting the provider using pact mock server ? We are starting the contract testing newly in our org and our stakeholders are interested to use the live service at the first place to generate the contract (as we have 1000+ micro services already up in production) and for those existing ones - preferring to use live rather than mock at the consumer end. Really looking forward for your response !
m
Hello Team, I have a generic question w.r.t pact consumer. Does pact support letting the consumer to generate the pact json file by hitting the real provider service instead of hitting the provider using pact mock server ?
Pact doesn’t no. It’s best thinking of Pact as a unit testing tool. Whilst you could definitely use a record/replay style tool to capture the requests, what you will lose out on is what fields in the response the consumer actually uses - this is an important part of the contract test. Usually, you only use a subset of them. Assuming you need the full suite, means that it will be harder for the provider to evolve. But, you might like to try it as a starting point, and then manually pare the tests back
If Pact is a bit of a hurdle to jump, you could look at https://pactflow.io/bi-directional-contract-testing/ (BDCT) to start with and then transition to Pact as you mature. BDCT is more schema based and might be an option to consider if you want to scale the tests more quickly.
p
Thanks Matt for the quick response. Yes that makes sense as the purpose of contract testing!
t
Does pact support letting the consumer to generate the pact json file by hitting the real provider service instead of hitting the provider using pact mock server ?
The point of pact is that you don't have to do this, but you get the same value as if you had.
💯 1
👍 1
p
Also have a follow up question. Hope pact supports running against the provider real service at the provider end (I mean without mocking the data layer) and running against the real service running say on dev common environment ?
m
Yes, you run against a real service. But it's best practice to do it in a unit test-like environment
This allows you to exert very specific control over how the tests run, and importantly, stub out external systems to make them reliable
p
Cool ! Thanks Matt
t
p
Yes have read it through and did spike based on pact jvm and mocks on both consumer provider ends. While trying to implement for POC we had this requirements from stakeholders. We explored and couldn’t find any examples at consuming end hitting real service. Hence this post for 💯 % confirmation from pact community 😊
👍 2
t
Awesome, makes sense. The people asking the question might be interested in that page too.