Microservice Clients Without Mocks, Part 2: Paranoic Telemetry
September 1, 2020
“Testing Without Mocks” Training
Jun62023I’m offering live online training for this material in four 3-hour sessions from June 6th to 15th. Register here.
To be notified about future “Testing Without Mocks” training courses, join the mailing list here (requires Google login).
For private training, contact me directly.
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.