I've talked about Test First Development a number of times, but the dirty little secret is that I haven't really been practicing what I've preached. I spent many years as a pre-sales consultant, and the normal pattern of development (if you can call it that) for an SE is "hack until it works". Well, over the weekend I was looking at the posting tool for the blog - now that there's a decent sized blog community here, the logic used to transform wiki style markup to html was just too much a hack for me to stand. So I sat down to redo it - and decided to actually write some tests.
In with the epiphany. What I've usually done is create ad-hoc workspace tests, and just gone with that. The problem is, those tests don't really work that well - there's no history, and you don't tend to retest old behavior as you add new behavior - so you miss bugs that creep in. This weekend, as I wrote my markup code, I created tests, and then wrote the markup code to push out what the tests expected. I had to change my approach a few times as I went through different forms of markup, and the tests showed me where I had broken things. Yeah, all of that is obvious - but it's not something I had been doing.
Now, I'm a believer :)