Pensieri di un lunatico minore

30 April 2006 Programming

Test-driven development and you

I have subscribed to most of the tenants of agile development for a while. I can trace it back to Kent Beck’s seminal book: Extreme Programming Explained: Embracing Change, which changed the way I view software as much as my discovery of Smalltalk had, and as much as my discovery of the Gang of Four’s Design Patterns book already had. Having said that, while I preach well from the pulpet, I do not always practice as well as I should.

So why is that? Often, it is the tools. Tools can be either a boon or a bane, depending on their suitability for the task at hand. When I’m writing in Smalltalk, the tools flow naturally and I am constantly writing tests. When writing code in other languages, I often find that writing tests consume more time than I think they ought to, and sometimes I even let them get done last—rather than first as one should with true test-driven development.

As I’ve started writing more and more Ruby code, I’ve enjoyed writing in the standard Test::Unit framework, which owes everything to the “mother of all testing frameworks,” SUnit that started the whole thing. Still, I have to actually run the tests for them to be valuable.

In steps ZenTest, and more importantly a little piece of it called autotest, which continually runs tests as you’re writing code. Every time you change something, the appropriate tests get run. After I read Geoffrey Grosenbach’s blog entry on the subject, and watched the accompanying video, I had to try it out. I’m hooked.

Combined with my use of DamageControl, I find that it’s possible to keep up with a “continuous integration”: cycle, and not have to worry too much about what I’m writing or refactoring.

Spiffy. In some ways they’re juts rediscovering what the Smalltalk world has had for a long time, but there’s a lot of new stuff happening too, and the “spirit” of the community is what attracts me. There is a certain unwillingness to accept wrote answers and look for new solutions. They also seem, unlike so many others, to not have forgotten where so many of the ideas come from.

This entry was posted at 9:15 pm on 30 April 2006 and is filed under Programming. You can follow any responses to this entry through the post-specific RSS 2.0 feed.

Very interesting. Now I’m really curious if there’s something like this for C and C++. Seems like an even bigger win for a compiled language.

Are these tools Ruby specific? Or could I use them for other languages?

I took a look at the web pages and they had very scant documentation on what they even do so I got kind of discouraged.

Some of the tools are Ruby-specific, and certainly the ZenTest tools are, but there may exist similar tools for other languages. The lack of a “compile-link” loop makes dynamic languages a bit easier to develop these tools for, but hardly an exclusive solution.

We’re not “rediscovering what the Smalltalk world has had for a long time” at all, we’re bringing over tools from Smalltalk that we like.

Well, what I meant was rediscovering Smalltalk, not the ideas. Perhaps it wasn’t clear. I do think the Ruby community, more than any other I’ve been a part of, is actually curious about where things came from and self-educating about the origin of ideas. It’s nice to see.

Honestly, things like autotest and ZenTest are partially the “same idea” in a new environment, but they’re also new ideas in and of themselves. That’s what I love most of all about the Ruby community.

Both comments and pings are currently closed.