Hi all, Recently started looking into Bi-direction...
# general
s
Hi all, Recently started looking into Bi-directional contract testing and wondering how it works with provider states. How does pactflow statically compares the contracts from both sides for different provider states. Can someone share their expertise on this one, please. thanks
party parrot 1
b
There is no such thing as provider state in bidirectional contract testing, as the contract isn’t replayed against a running provider but compared to a static provider spec. You can use a Pact-generated contract as the consumer contract in BDCT, but the provider states are ignored by PactFlow.
☝️ 2
thank you 1
s
Thanks @Bas Dijkstra, So when there is an interaction for user not found for example and the interaction recorded with 404 not found, then pactflow will statically compare the response schema with the corresponding model for 404 in openapi spec? If so, what if there are more than one response models for 404 in Openapi spec.
I couldnt find any examples in the docs/videos for how we can verify contracts using OpenAPI spec with different responses provided by an endpoint. For example, docs/videos has
user exists
but not
user does not exists
scenario. Hence the above question.
b
It does handle different responses for the same endpoint. In this video, I do a demo of BDCT (43:00 onwards) with a consumer contract with multiple responses (200, 400 and 404) for the same endpoint:

https://www.youtube.com/watch?v=3lZq4IyZ7poβ–Ύ

Here's the corresponding code: https://github.com/basdijkstra/introduction-to-contract-testing/tree/bdct_example The OpenAPI spec is in there, too, so you could use this to replay it and see what happens.
s
thats cool, Thanks for it. Watched videos in pactflow channel but missed this one πŸ™‚ Appreciate your prompt response and resources shared.
πŸ™Œ 1
@Yousaf Nabi (pactflow.io) / @Matt (pactflow.io / pact-js / pact-go), pact docs states that bi-directional contract testing has weaker guarantee. Can you please elaborate on this one a bit please if it is okay with you. Is there any disadvantage replace CDCT with BDCT? thanks
m
The docs talk about those guarantees, what's not clear? See also https://pactflow.io/blog/schemas-are-not-contracts/
The tradeoffs are also there in the docs. Only you can decide if your situation better maps to CDC or BDC
πŸ‘ 1
s
Thanks for sharing the blog post on this, it is helpful.
πŸ™Œ 2