Microservice Clients Without Mocks, Part 2: Paranoic Telemetry

Every week in my Tuesday Lunch & Learn livestream, we choose a useful software development skill, define a challenge related to that skill, and solve the challenge live. This week, we’re finishing our two-part series on testing microservice clients.

In today’s episode, we finish off our ROT-13 tool by using last week’s generic HttpClient class to build a dedicated client for our ROT-13 service. Calling the service is easy; the real challenge is making sure that our code is robust against errors. With services, anything that can go wrong, eventually will go wrong, so we need to make sure our code can handle anything.

In addition to handling errors, we also make sure that all our code can be tested without mocks. This involves making our ROT-13 client nullable and trackable, and we also program it to generate errors on command. This lets us test how our application code deals with client errors.

To follow along, download the code from GitHub and check out the 2020-09-01 tag. To see the final result, check out the 2020-09-01-end tag or view it on GitHub.

Visit the Lunch & Learn archive for more.

If you liked this entry, check out my best writing and presentations, and consider subscribing to updates by email or RSS.