I’ve had been hearing about test driven development for a couple years now, and I never really paid too much attention to it from a practical level until recently when I started getting more interested in the .NET MVC. I’ve been playing around a lot with the MVC Storefront Sample, and I am realizing just how cool and helpful that the test driven approach can be. However, I’ve been programming using a ‘test last’ approach for a long time now, and when it comes down to business, I can always best estimate my effort with the approach that I am most familiar with.
I’m guessing that learning how to use the test driven approach is less like learning another programming language, but more of a change in how you approach laying the framework for, and planning the requirements for building an application. I don’t think I could just pick up a book and start a project for one of my clients using TDD, I’m guessing my introduction to it need to be more methodical.
What is the best way for me to shift my mind-set of planning to build an application so I can become effective with test-driven development in the shortest amount of time?
The best way to pick up TDD is to go ahead and do it. That’s the only way so far I’ve manage to get co-workers ‘test infected’ – at least right now you have a good appreciation of the benefits upfront.
From a more practical point of view though, I think you already have highlighted one of the key ideas – it’s a change in planning the requirements for building an application. Whatever methodology you’re currently using, if you see a word like ‘requirement’, you can mentally think ‘test case’, and at least have the intent of writing the test case first. But just like the other answers suggest, TDD isn’t an all-or-nothing decision. Any test you write, whenever you write it, before or after, is helpful. Likewise, don’t think you can ever get to a state where you write all the tests upfront – it’s a cycle.
A favorite of mine is the pseudocode iat the end of this item in the JUnit FAQ. The test case frame of mind is an infinite loop. Jump in anywhere, any test you write will help, and you won’t regret it.