Geeks With Blogs

News INETA Community Speakers Program WTFNext's hosting!

View Stacy Vicknair's profile on LinkedIn

WTF Next? Dev ramblings from a master of nothing.

nunit My work environment is usually an anything goes, wild west of development sort of place. There are no rules imposed, just a “get things done” attitude. Because of auditing, source control was a necessity that got added to the mix. We use SVN through VisualSVN Server and TortoiseSVN as a client.

Well, as a part of self improvement and to produce better more reliable code, I’ve taken up learning TDD for myself. Our current methodology of testing here is based mostly on WTFs per minute and copious prayer. This time around, I’m trying super scoffable alternative: automated testing and continuous integration. Tests better than no tests? pshaw.

So, when trying to read resources on TDD, getting started always seemed difficult. I even tried the book TDD By Example to see if that would help, but it seemed sluggish to read along and try these minute tests that don’t apply to my real world applications. I started trying to integrate TDD in a small project for work instead.

As a result, I can say I’m experiencing the benefits of TDD already. When I refactor or write new code, I’m confident that I’m doing it for a reason. If the tests fail, I know what exactly is failing and can isolate it.

Today, while writing tests, I somehow created a never-ending loop in code (must’ve been evil code fairies I swear.) This gave me my first problem with my TDD experience: How do I debug code for a partially constructed application, when all I’ve got to go on is that I know it doesn’t work?

Well, here’s what I was able to do.

  1. Added a new console app project to the solution called Testing.Debug
  2. Extracted my unit test and put it as the sole code in the console app.
  3. Added a break point where I knew my problem was happening.

I knew the where, but I couldn’t discern the what. After running the small testing app I found it quickly and fixed the problem.

So my question to those of you who do TDD often, how would you handle the situation? How do you handle situations that might call for a debugger?


Technorati Tags: ,,,
Posted on Wednesday, March 11, 2009 4:26 PM VB .NET | Back to top

Comments on this post: How NUnit and TDD helped me today

# re: How NUnit and TDD helped me today
Requesting Gravatar...
As an update, I've needed the debugger once more to tell if my application is looping correctly. Is this a problem with my tests or is this a shortcoming of TDD? I was under the impression most TDD'ers would roll back code instead of debug, but I don't see myself doing that when writing a new test.
Left by Stacy Vicknair on Mar 11, 2009 4:50 PM

# re: How NUnit and TDD helped me today
Requesting Gravatar...
I have projectClasses which contains my "business layer".

I have projectDeliverable which references projectClasses and contains the UI and validation.

I have projectUnitTests which referencesClasses and contains my suites.

I have projectTestHarness which references projectUnitTests and allows me to call a unit test directly and step through it. I feel that using the test harness is bad, I guess a code smell. The tests are supposed to be so simple that I should not have to step through them -- right?
Left by Duncan on Mar 24, 2009 4:00 PM

Your comment:
 (will show your gravatar)

Copyright © Stacy Vicknair | Powered by: