Episode 40: Better Built By Burkhard

Doing TDD with I/O-Free Tests

I’ll change my publishing schedule slightly. In the future, you’ll receive my newsletter on the first and third Monday of the month - instead of the 1st and 15th day of the month. I will occasionally skip the newsletter on the third Monday of the month in favour of a blog post on my website. I have been struggling lately to write at least one blog post per month. Now enjoy the newsletter.

Doing TDD with I/O-Free Tests

In my post Applying TDD to Classes Accessing Files, I stated that “bad unit tests read from files”. In more general words, unit tests doing any kind of I/O are bad. I went on to define good unit tests as FIRST following the definition by Tim Ottinger and Jeff Langr: Fast, Isolated, Repeatable, Self-verifying and Timely.

This definition is still unwieldy and invites tedious discussions about what a unit test is and what not. I had too many of these over the years. In the spirit of KISS (Keep It Simple, Stupid), I should have defined unit tests as I/O-free tests. That’s exactly what Ted M. Young does in his insightful post I’m Done with Unit and Integration Tests.

Read next