Thursday, October 18, 2012

Test first, code later...

Another day, more proof that the first stroke of your finger in vim or whatever your favorite editor is, should begin with public class ...Test.
I prove this to myself altogether too often.
Whatever, I've never been on a project, even one with which I have so much to do as the present, for which there are myriad tests missing almost from day one.
Today, I went to tackle some "clean-up tasks" postulated in a distant sprint planning as something we'd need to get around to. Circumstances made it so that I needed to pitch in to help an area that's not ordinarily mine. So, I immediately set about adding tests for the little details I figured a couple of months back might need particular attention.
As the French say, Ben, voyons ! And how! Handling of nearly every one of the little details was either absent or seriously compromised. The test bits, which I wrote in JUnit using Mockito to eliminate any connection to wire, database or stuff that would defeat total automatization, were tiny, but they did the trick. In the space of probably two hours, I had the tests written and the implementation fixed.
For this, I can only thank my old friends from Brisbane, Dean Povey and David Leonard, for teaching me the maxim that is the title of this post. I'm only a deacon in this church of writing tests first, coding afterward, but I hope to become an ordained priest before much longer.

No comments:

Post a Comment