Say we have a CreditCardService microservice that depends on a ThreeDSecureService microservice, communicating using JSON.
Minor changes in the API (or even implementation) of the ThreeDSecureService could silently break the CreditCardService (and other potential clients). So, we would like automated tests.
I see two flawed approaches, and am wondering how to improve.
- Integration testing in ThreeDSecureService.Tests.
The accompanying test project of ThreeDSecureService could have an integration test with a fixed JSON input. Faking out any dependencies, it could run an otherwise complete call for that input, confirming that the service swallows the input.
The problem here is that if someone fails to realize how their changes could break clients, they are almost as likely to 'fix' the tests to match their changes.
- Integration testing in CreditCardService.Tests.
The client is the one that actually wants to test assertions about ThreeDSecureService's expected input. However, that would require the client solution to include the ThreeDSecureService project, as well as any projects it depends on. This would negate many of the advantages we get from using microservices!
How do we make assertions from the client (safeguarding the dependency) without breaking the loose coupling we get from using microservices?