Microservice Clients Without Mocks, Part 1: HttpClient

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 starting a two-part series on testing microservice clients.

In today’s episode, we build a generic HttpClient class that can be tested without using mocks or integration tests. There are two main challenges: First, we need to build the client itself, which requires that we implement a small Spy Server so we can test that the client works properly. Second, we need to make the client testable without mocks. This involves making it nullable, configurable, and trackable.

To follow along, download the code from GitHub and check out the 2020-08-25 tag. To see the final result, check out the 2020-08-25-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.