How Test Driven Development proved itself in a big way! - ISerializable - Roy Osherove's Blog

How Test Driven Development proved itself in a big way!

Over the past year or so I've been going around trying to tell people how and why test-driven development will help their development process. Its hard to convince people. It's actually still hard sometimes, even after people have had real-hands on experience (after attending one of my TDD workshops). Why? because its just too good to be true , sometimes. And being afraid of what to tell your boss matters too.
 
So here's a good story you can tell around the camp fire. Today I've experienced one of the most gratifying results of writing unit tests. We have a system that is near production ready, which involves lots of layers, logic and data. Today we had to do one of the most scary things you can do to a system that is near production - change the indexes of most of your database tables, including some primary keys, then go through all the stored procedures and change them to fit this new schema. How scared would you be?
 
Heres how it worked for us:
  • Downloaded CodeSmith (awesome application, that.)
  • Created a simple template for stored procedures against all db tables
  • Ran the script against the database - generating only DELETE procedures
  • Ran all the tests
  • 5 tests out of about 200 failed
  • We tweaked the procs a little by looking at the old database
  • Ran all the tests
  • All the tests were green
  • We continued the same process for Update and Select procedures.
  • It took 4 hours to complete this whole experience, with all the tests running in the end.
Imagine doing this on your system today. Would you even consider it?
This is agility in its truest form: The ability to make changes to the system when you need it. And knowing what breaks when you actually do it. And being able to fix it and know that you actually did fix it.
I could easily say that the Unit Tests paid for themselves just from today's experience. not to mention the amount of time they have already saved thus far. I am now throughly convinced that Test-Driven development is one of the best ways to tackle, if not reduce, the amount of risk in today's average IT project.
 
If you're all now thinking "we don't have time to incorporate the complete "Extreme Programming" process into our Dev team - you don't have too. the project I'm talking about is NOT doing full on XP. however, TDD is a big part of it, as well as customer on site and refactoring. Some pair programming was done in several parts of the project, but not all of it.
 
I can certainly say that had we not had unit tests - we would be doing today "Prayer Programming" :)
Published Thursday, September 09, 2004 6:06 PM by RoyOsherove

Comments

Thursday, September 09, 2004 8:14 AM by TrackBack

# Dazed & Confused » Sunshine TDD story

Dazed & Confused » Sunshine TDD story
Thursday, September 09, 2004 11:23 AM by Chris

# re: How Test Driven Development proved itself in a big way!

I'm sort of in the middle of this as well. I'm in the middle of phasing out a middleware client/server product and replacing it with a homegrown one before a system upgrade. This is happening in two parts: I. Rewrite the client, II. Rewrite the server.

Writing the client was easy. The API stayed the same, and I simply wrote unit tests to mimic the API/behavour of the existing client. When all tests passed, the new client was ready to go.

The next part is even more joyous with unit tests. I wrote tests to mimic the expected behavour of the server I/O. Once those passed using the old software, the same tests were run using the new server software. ONce those passed, it was a whole lot easier to sleep at night after replacing the old server software with the new.

I can't really imagine doing any of that without unit tests.
Thursday, September 09, 2004 12:49 PM by James Snape

# re: How Test Driven Development proved itself in a big way!

I hear you... Just one point though - we are finding that once you have shipped a version then changing the schema becomes a very big deal. No customer is going to allow you to upgrade or fix if it means they lose their data.

Changing indexes is also another interesting issue - do you have tests that check query performance? How about interactions between different queries? We recently added a new index to a system which caused all sorts of locking problems when accessed by a couple of hundred clients (the customer was a TV company using the application to display live data on screen as well).

James.
Thursday, September 09, 2004 1:45 PM by Anatoly Lubarsky

# re: How Test Driven Development proved itself in a big way!

Changing indexes + fine performance tuning is just an issue of the full time production database. From the other hand database schema - is the thing you begin your application from. It is not supposed to change.
Thursday, September 09, 2004 6:39 PM by TrackBack

# New Team System Stuff - 2004-09-09

Friday, September 10, 2004 5:43 AM by TrackBack

# How Test Driven Development proved itself in a big way!

Monday, September 13, 2004 8:57 PM by TrackBack

# How Test Driven Development proved itself in a big way!

Monday, September 13, 2004 9:08 PM by TrackBack

# How Test Driven Development proved itself in a big way!