Creatively Thrashing With TDD

One thing I've never seen anyone do, for real, is Test-driven Development. We've all sat through the demos of "Red, Green, Refactor" and the To-do list - but never have I seen the presenter do something "Real". That changed last week and it was pretty fun.

Tekpub just released “Full Throttle: TDD with Brad Wilson”  and during the recording of it, I threw as many “real-world” hand grenades as I could at Brad to see how he would handle it.

The premise was that Brad needed to create a subscription billing system that fires off periodic billings and also updates the Customer record – using C# and xUnit.net (Brad’s testing framework he created with Jim Newkirk). To many, this sounds simple. To those that have implemented such a thing – it’s anything but.

The thing that I really, really enjoyed about this episode is that I pushed Brad just enough to remove the “demo veneer” – I gave him a curveball about 30 minutes in where I said “Oh yeah… did I mention that we also do X?” – and he had to adjust. 

When you have a mess of tests that assume one thing, then you have to shift to another – it’s a pain in the ass. But Brad handled it amazingly well – taking the opportunity to push more structure into his testing process, then one by one “transition” his old tests into the new approach.

We worked the whole hour inside a single code file – and I’d never seen anyone do that before. Sure, I’ve created a class right there inside the code – but watching Brad spin up class after class, then rename, then delete, then completely restructure his tests… it was very, very interesting.

They always say is a “design process” – yet I’ve never seen it used in a truly “design-y” way – like a painter might toss color after color on a canvas until it looks/feel just right. And that’s exactly how it felt watching him.

About 15 minutes in Brad mentions that “I leave a class in the test file until it’s ready to go public” – meaning that he has enough tests to justify his design decisions. A concept I’d never really thought about before – sort of like using the test file as a bit of a “womb”.

He “felt” his way through the creation of the billing system – talking to himself the whole time and creating something rather interesting and pretty damn close to what we ended up with after close to 3 years being live.

I hope you enjoy it. I sure did.

Tags: