By Peter Bell

Getting Test Infected

One of the things I've heard time and time against is that the best way to learn TDD is to pair with someone who's been doing it for a while to get "test infected". Unfortunately I don't have someone to pair with who has TDD experience, so I've been "infecting myself". Here are some of the things that I've been doing and how it's been working out for me . . .

The starting point for me was reading the key books on TDD (my focus is TDD on the basis that it provides more benefits than Unit Testing alone and that if I'm going to change how I do things I'm just as well to change them to a better way of doing things!).

I also joined the Test Driven Development Yahoo! group to get that slow drip feed of TDD ideas into my inbox, keeping some share of mind on TDD and seeing the kind of issues practitioners were facing.

I've also got to say that presenting at conferences like ooPSLA and SPA put me in an environment with people like Kent Beck, Martin Fowler, Ward Cunningham and the next generation like Dan North and Liz Keogh which made it pretty embarrassing NOT to have been doing TDD for the last few years, so that certainly helped with the motivation to "get" TDD before Nashville!

Recently I finally got a couple of quiet days to get started and a perfect use case. I'm re-writing my in-house framework from the ground up and it is quite a bit more complicated than anything I'd usually code for a client and the robustness and handling of edge and exception cases is extremely important as I really need to be able to trust the framework. It's also a perfect example of trying to create a very powerful system that could result in analysis paralysis, so it's a perfect fit for a Test Driven Development approach. I IM'd many of the smart people I know to get their input on structuring, naming and writing tests.

I'd already installed the excellent MXUnit (although don't forget CFC Unit or CF Unit), so I read through the JUnit book, put together a few blog postings, and now I have my new IBO project (I'm starting by rewriting the IBO which LightBase uses extensively) including a test directory with a generated test class ready to be filled out with a set of useful tests. I'm going to cheat a little with the base object. I've already coded something, but I'm going to delete the code (including the class file) and start from scratch writing the tests first. It'll be interesting to see if the API I end up with from TDD is simpler or better than the one I originally came up with . . .

Comments
Random thought: I wonder how feasible it would be to use Sean Corfield's scripting for CF to use JRuby (or another scripting lang) to write tests for CF.
# Posted By Sammy Larbi | 4/16/08 1:52 PM
Sorry, didn't mean to get off topic. Just the mention of JUnit and CF and been working in Ruby all day. I don't expect you to answer that. =)
# Posted By Sammy Larbi | 4/16/08 1:53 PM
Interesting question, but a little too off topic for me today. Let me know if you find out :->
# Posted By Peter Bell | 4/16/08 2:24 PM
BlogCFC was created by Raymond Camden. This blog is running version 5.005.