Moises Siles
06/21/2023, 3:35 PMBas Dijkstra
06/21/2023, 5:01 PMMoises Siles
06/21/2023, 7:29 PMBas Dijkstra
06/21/2023, 8:20 PMMoises Siles
06/21/2023, 9:45 PMBoris
06/21/2023, 11:22 PMMatt (pactflow.io / pact-js / pact-go)
GM team, I’m wondering about the process with contract testing... person in charge of the contract tests(dev/qa) should mock the provider and consumer, is that right? or should that person use the actual API code to make sure we are hitting the endpoints with the correct parameters?The way to think about Pact tests is to treat them as if they were a unit test. Once you have that frame of mind, how you test becomes a lot more obvious.
Currently what I’m doing is creating the provider/consumer tests and I’m defining the methods with the post/get adding the headers, etc.... but I’m not using the app code, I know what the endpoints are and I’m using Postman to get more information about headers, response, etc. This is the piece that’s not clear to me, should we mockup everything (provider/consumer)? or basically we should use the real API calls from the code?You only mock the boundaries, but obviously you want to be testing the behaviour of the code under test. On the consumer side, this is the API client. Usually you wouldn’t have to mock too much here, except of course the API provider (and Pact will provide that mock). On the provider side, this is usually the whole API and you would mock downstream / 3rd party systems
What happens if the devs change something in the actual API code and they don’t tell me, my tests will continue passing because they are not hitting the updated code. Does that make sense?Yes, it makes sense, but you shouldn’t be doing it this way if you go back to the “it’s a unit test”. Really, these tests should live alongside the code and would change with the code. If your contract tests continue to pass when the implementation changes, you’ve done it wrong. Contract tests aren’t regression tests or acceptance tests to prevent behaviour changes - they can and should change. Pact and the broker will ensure the various components remain compatible
Moises Siles
06/22/2023, 2:04 AMMoises Siles
06/22/2023, 4:23 AMBoris
06/22/2023, 4:37 AMBoris
06/22/2023, 4:40 AM