Nullable Output

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, it’s nullable output.

In previous episodes, we’ve talked about the Nullable Infrastructure Wrapper pattern. It’s a way of testing infrastructure code without using mocks. This is valuable because it allows us to write unit tests that don’t need backup integration tests.

Nullable Infrastructure Wrappers work by “turning off” their connection to the outside world. So how do you test code that sends data? For example, if you make a call to a microservice, or write output to stdout? One way is to store the last output, but that only tells us the last thing that was sent. What if we need to test multiple writes? In today’s episode, we solve this problem.

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