In a previous post “Fluent async testing,” I introduced a sample library to beautify unit tests relying on Task-based assertions. Tests for this type of library typically make heavy use of “canned Tasks” to ensure every case is handled correctly.…
Wake up!
In Effective Unit Testing: A guide for Java developers, author Lasse Koskela writes about the scourge of the sleeping snail — slow tests littered with calls to Thread.sleep. His suggested alternative is perfectly sound and practical: turn nondeterministic waiting into…
From sync to async: SQL
Previously I discussed some common sync scenarios using network and file I/O and how they can be migrated to modern async patterns. Today I have an addendum about asynchronous programming with SQL connections. Let me start by saying that async…
Gratuitous complications: unit test fault injection
Sometimes things don’t need to be complicated. I would go so far to say most of the time things don’t need to be complicated. In the words of Uncle Bob Martin, “it is the software engineer’s job to make tough…
Binary explosion
How many binaries do you need for a .NET project? How many is too many? Does it really matter? I’ll admit I have a strong aversion to the phenomenon which I’ve dubbed “binary explosion” — tens (or hundreds!) of tiny…
Disorderly fault injection
Fault injection is a commonly used testing technique to force the system under test into failure paths, allowing observation and evaluation of the system’s ability to tolerate and recover from errors. There are many fault injection tools available, such as…
Null objects, not values
The Null Object pattern is oft-cited but not-oft-enough used (in my experience). After all, which looks more elegant/maintainable/object-oriented? The difference is subtle but important. Not only do null checks go away in the Null Object world, but overall responsibilities become…
Interfaces: sync or async?
Given an extensible interface, how should one decide whether to define synchronous or asynchronous methods? (Note that in this case I mean interface in the general software engineering sense, so feel free to substitute base class, exported DLL function, function…
Exception contracts (or lack thereof)
Visual Studio’s Code Analysis for Managed Code (formerly known as FxCop) has warned for approximately a decade against using generic catch (Exception) blocks. Many strongly-worded articles and blogs have been written to explain the reasoning. Perhaps even more digital ink…
A loop is a responsibility
A lot has been written about the single responsibility principle over the years. Rather than rehash what many others have said better, I want to give a common example of how a seemingly innocuous control structure can subtly but surely…