0

Let's say I have microservice A and B.

Microservice A calls microservice B for some piece of information.

Microservice B requires parameters 1, 2, and 4 for the request to be valid.

If I'm simply mocking the API call & response between Microservice A and B, how does that enforce the contract for B, in that, B requires parameters 1, 2, and 4?

4

If I'm simply mocking the API call & response between Microservice A and B, how does that enforce the contract for B, in that, B requires parameters 1, 2, and 4?

If you mock the test such that service A submits the right data in the right format, and processes the right result and service B accepts the expected data and returns the proper result in the right format. Since the units do what they are supposed to do, you have higher confidence that the code works properly.

To test that each unit of code’s expectations actually match, you get to wire them together and run an integration test. (Or do it manually via a smoke test). Generally, things aren’t mocked in an integration test, because that defeats the purpose.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.