Darrell Norton's Blog [MVP]

Sponsors

The Lounge

News

  • Darrell Norton pic

    MVP logo

    View Darrell Norton's profile on LinkedIn

    Currently Reading:

    weewar.com

Advertisement

Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
Another TDD Sucess story

It’s so easy to work with Test Driven Development. For example, I recently had to go in and debug a data access method. Well, I was supposed to just add tests for it, but I ended up having to debug it. Hehe.

There were 3 DataTables, so instead of testing all three at once and trying to figure out the error I was getting, I commented out two and just returned the first one in the DataSet. Green!

Ok, then I enabled the call to the database for the second one. Red! So I looked at the stored proc and typed dataset, quickly figured out it was a mapping issue, and fixed the stored proc. Run NUnit again. Green! Finally I re-added the last DataTable code and ran NUnit. Green!

All done and no debugger was necessary (sorry John Robbins!). And this only took a couple of minutes. All it takes is for you to start using TDD where you can. Just start by writing some tests around some code that you work with every day. I guarantee it will help.


Posted 05-27-2004 9:05 AM by Darrell Norton

[Advertisement]

Comments

Steve Hebert wrote re: Another TDD Sucess story
on 05-27-2004 5:24 AM
Very cool! Great example!
Steve wrote RE: Another TDD Sucess story
on 05-27-2004 5:43 AM
The debugger is evil! Whenever I start stepping through a peice of code in the debugger I know my tests aren't good enough. Anyway, great example of how TDD can be used on existing applications to help "debug" an application!
Darrell wrote re: Another TDD Sucess story
on 05-27-2004 5:48 AM
Thanks to both of you!

Steve (Eichert) - good point about knowing your tests aren't good enough if you have to use the debugger.
Dave wrote re: Another TDD Sucess story
on 05-27-2004 6:08 AM
As someone who is constantly trying to get more people into TDD, this is an example I'll be sure to use. Nicely done.
Darrell wrote re: Another TDD Sucess story
on 05-27-2004 7:01 AM
Dave - thanks. The funny thing is, I was wondering whether this was even blogworthy or not.
Paul Bartlett wrote re: Another TDD Sucess story
on 05-27-2004 9:24 PM
I don't think there's any need to apologise to John Robbins. IIRC, he more than most thinks developers spend to much time "in" the debugger when solving problems.
Darrell wrote re: Another TDD Sucess story
on 05-28-2004 1:35 AM
Paul - yeah, I was just joking. Some WeProgram.NET user group members (my user group) talked with him about debugging. But if TDD reduces the need for debugging, he won't sell as many books. :)
A'braham Barakhyahu wrote re: Another TDD Sucess story
on 12-03-2004 4:03 AM
How would you TDD a DAL which calls a stored procedure that has joins? I'm doing one part of a bigger project, where writing procedures to created and delete the tables involved would take a bunch of time. I can pull the expected data manually, store in a datarow and compare to the one i pull, but that's doesn't seem like the best solution. Any suggestions?
Darrell wrote re: Another TDD Sucess story
on 12-03-2004 4:56 AM
A'braham - that's actually what I do for a couple of reasons.
1. It's fast.
2. It is probably the best check to see if what you are doing is what you intended to do.
3. It's clear and easy to understand.

I'm sure there are other ways, maybe even better ways, to do it, but for now that's what I do.