Today’s discussion promises to be brief and to the point.
Halloween is fast approaching here in the United States, and it strikes me that goblins aren’t the only thing that frightens Software developers.
There is something to be said when a codebase matures and the attitude of the business unit and software development team shifts to one of:
If it ain’t broke, don’t fix it.
I would argue that, at times, we software developers often find ourselves in organizations in which this attitude is pervasive.
This fear-based mindset is indicative of a codebase in which the context for past decisions has long been forgotten.
Such fear stagnates further evolution of the underlying code and makes the cost of introducing new ideas progressively intractable.
But, we need not find ourselves in this situation, as this is the reason for having a reliable unit test suite.
You should not be afraid of your code. Your code should be afraid of you!
You may have been led to believe that the purpose of a test suite is to measure code coverage, but such numbers are pure vanity.
A test suite’s sole value is the freedom to refactor at will in response to an ever-changing context and roadmap.
What a team knows about a problem domain at the outset is always a guess.
Experience, in the form of customer feedback, illuminates the true nature of the domain and beckons the code to flex to match this new clarity.
This juncture is where a test suite shows prowess, as changes are crafted with high confidence. Just to let you know, I did not state a 100% guarantee. This degree of certainty is and will never be attained.
So, the next time you weigh the value proposition of testing your code upfront, keep this understanding in mind, as those teammates who follow will thank you.
I highly recommend xUnit Test Patterns: Refactoring Test Code if you are beginning your unit test journey or seeking to sharpen your craftsmanship. The book was published in 2007 with a .NET audience in mind, but the patterns it offers are timeless and remain valuable regardless of your framework of choice.
Your feedback is welcomed as always.
You no doubt have an opinion bubbling to the surface.