[Best practices] How many contract tests should on...
# pactflow-ama
j
[Best practices] How many contract tests should one endpoint have? What criteria should I have to asses? complexity? stability? Let's consider phases of Contract Test intro in ecosystem: 1. getting started, onboarding new service 2. New contract in onboarded service 3. business as usual, securing service
m
I don’t believe it is a matter of a number of tests but instead testing what your consumer expects from that endpoint.
j
yeah, but there is a commonsense. what might be the rules to help me say: it is enough / too much / too few
s
Here is what I had done in past. In both frontend and backend code (consumer application), the code responsible for hitting provide, processing it, and then returning a response is part of util. I would look at the util and see how it is behaving against the response. If the util is checking two scenarios, one happy (200) and one bad (4xx), I would add two separate interactions -- one for each. This has been good enough as it allowed having contract tests only limited to testing instructions and not turn into provider functional test.
m
There is some best practice advice here: https://docs.pact.io/consumer
The main advice is avoiding functional tests, different types of data or large numbers of permutations
j
that is a perfect summary, thank you!