I’ve been writing Test Driven code for the last few years and it’s become a natural part of the way I write most code. It was only recently that a co-worker, relatively new to Test Driven Development commented on something I’d never taken notice of.
We were in the midst of some work and ended up with some strange behaviour when we clicked through our application. We inspected the tests to ensure all the tests looked like they were working, and then proceeded to fire up the debugger. My pair then commented, “I’ve noticed you rarely use the debugger when you Test Drive your code”, and you know, he was very correct.
I wouldn’t never say you never need to debug during Test Driven Development (especially when it comes to diagnosing system state and certain triggers) but you definitely spend significantly less of your time in debug mode as you’re verifying bits of your code along the way. And that’s certainly a better place to be.
What I also found when I moved to test driven development is that i did far less logging in my code, and eventually have gotten to the place where I only log events / details that would be of interest to an administrator of the application. Since I work in admin and development, i see the problem that arises from poorly thought out logging practices.
Now, when I write log messages, i write them test first. A technique I picked up from Jeff Langr’s excellent book “Agile Java”.