Jordan Nazemi
05/12/2022, 8:25 PMMatt (pactflow.io / pact-js / pact-go)
When doing the API testing of a Provider whats the best way to deal with it further downstream providers? For example, we have a cart-service that calls a promo-service when finalizing an order. If were setting up a contract where cart-service is the provider being tested using a Dredd implementation (like the workshop on bi-directional) would we want to mock the promo-service using a hook while running the API test? Should it instead still interact with a live version of the promo-service? If we do mock them, how we best ensure the mocked responses are accurate to the actual promo-service?WRT the contract test itself, it doesn’t really matter with BDC. The goal here is to ensure your provider is compatible with its OAS. This being said, I’d tend to want to run this is a unit-test like environment, and stub the downstream dependencies.
Matt (pactflow.io / pact-js / pact-go)
When using bi-directional in a pipeline whats a common method of removing the test-data generated during the API testing step? Would you use, say, an afterAll hook set up in Dredd to clear the test data that was generated or should we mock those external database calls?I think there might be an assumption here is that you run this against a live environment. You can do this, but the answer is “whatever you normally would do for a functional test of this environment”. I would, again, usually tend to want to do this in a controlled unit test-like environment, where this isn’t a problem