Monday, August 29, 2011

Learning to Love Test-Driven Development

I'm a pretty decent programmer (OK, maybe I'm a bit rusty since my primary job responsibility isn't development). One facet that I've ignored though is the value of rigorously testing my code. Oh, sure, I run my code and try various things to make sure it does what I want under normal circumstances. But that's not the same as writing formal tests that cover a wide variety of inputs and conditions that your code needs to deal with. Taken to the extreme, test code should be written first, and then the "real" code gets written.

I haven't done much with writing test cases because the code that I write these days for the most part are short scripts for automating day-to-day tasks. Also, writing test code is something of a mindset that you have to practice.

I'm going to work a lot harder at writing test code, partly because it'll improve the code that I write for my own use, but also because many open source projects that I contribute to require tests for any new code (or for any old code that gets changed).

0 comments: