Pages

May 13, 2008

First Taste of TDD

Yes, I am one of those people who have fallen behind the curve. Until today I had not joined the ranks of the Test Driven Development enthusiasts, but now I am certainly one of them. I have been working on a reporting application at work that has a list of very vague and constantly changing requirements. The only thing that has not changed is that the application must be able to execute report definitions and export the output to one of seven file formats. As you can guess, the thought of having to run a report definition against my application seven times each time I was going to make a tiny change to see the effect was not appealing. So I turned to TDD.

Now I have done a lot of reading on the various xUnit test frameworks, but had never actually used any of them. I was a little worried that it would be difficult, but I got through the NUnit install fairly easily and had four test fixtures implemented by the end of the day. I saw my fair share of the dreaded "red bars," but I am proud to say that by the time I left for the day I was seeing nothing but green.

I am so mad at myself for not trying this out earlier as it would have made my life so much easier. I remember in the past having to do long build and deployments to test a small change to make sure it had not changed the expected business logic. All that time I could have been just looking for the green, haha.

Now I just need to find some good TDD books so I can convince the guys that sign the checks that it's the way to go. I know.... Good luck with that, haha.

1 comment:

  1. Unit testing is addictive. It also has the nice side effect of making people write better code. Large, ugly, kitchen sink methods are not only poor design, they are also really hard to test. I don't know much about the .NET world, but for java I'd recommend "Agile Java" by Jeff Langr.

    ReplyDelete