A Unit Test Success Story

I spent the past few days closing out PurpleWiki bugs in preparation for our impending v0.9 release. And once again, unit tests saved my butt.    (3I)

Automated unit tests are like programming with a net. You invest a little bit of time up-front writing the test, and then you save a ton of time later. Most importantly, unit tests give you confidence to experiment. You can dramatically refactor your code without worrying about unknowingly breaking something.    (3J)

I’ve used unit tests on a number of small projects, and have been pleased, but not overwhelmed with the results. However, my experiences with unit tests and PurpleWiki have been extremely gratifying. Our unit tests have consistently caught bugs that might otherwise have stayed hidden for months, even years.    (3K)

Extreme Programming (XP) advocates writing tests before writing code. I cheat a bit here. I usually write a few test cases, write the code, then write the automated unit test. Same goes for bug fixes. More importantly, we mandate a unit test for every bug fix. If changes to the source code revive an old bug, the corresponding test will catch it immediately.    (3L)

On a related note, I ran into Chris Sepulveda, an old college acquaintance, last week. He’s been an XP consultant for several years, and he recently moved from NYC to the Bay Area. We had an excellent discussion about XP patterns and adoption. In particular, he bemoaned how narrow thinking about the methodology prevented many people from incorporating it into their processes effectively. XP is as much about philosophy as it is about methodology.    (3M)

Chris is loaded with good thoughts, and is slowly but surely sharing them with the rest of the world on his blog.    (3N)

Leave a Reply