How do you unit test a microservice that makes a call to another microservice?

by john   Last Updated June 15, 2018 01:05 AM

I have a suite of microservices:

  • ConnectorRegistrar
  • ConnectorTypeA
  • ConnectorTypeB
  • ...
  • ConnectorTypeZ

"Someone" can make a call to the ConnectorTypeA microservice to create a connector of type A, and it is needs to be known that "Someone" is the owner of that connector.

When ConnectorTypeA is created, it needs to register itself with ConnectorRegistrar.

The obvious option is to have ConnectorTypeA make an API call to ConnectorRegistrar to let it be known that "Someone" owns ConnectorTypeA.

The dilemma that I'm facing is I am not sure how to unit test this.

When we do the unit test for ConnectorTypeA creation, it will mock a creation through a database transaction. But if the API call is making another API call to the Registrar service, the Registrar will be making a record as well, which is wrong... as the unit test shouldn't trigger a permanent record.

Can someone please help me and point me in the right direction?

Thank you



Related Questions


What does stubbing mean in programming?

Updated March 03, 2017 13:05 PM

Integration tests, but how much?

Updated February 28, 2017 08:05 AM

i want a postman's counterpart for mobile developers

Updated December 05, 2017 07:05 AM


Test Internals with TDD?

Updated March 08, 2018 04:05 AM