Subj : Re: Not debugging? To : comp.programming,comp.lang.java.programmer,comp.lang.lisp From : Phlip Date : Fri Aug 26 2005 07:31 am Peter Ammon wrote: > I've been waiting for someone to make this claim about unit testing. Guess > I'll pick on you :) Oh goody 'cause I didn't claim it. [I think.] > I don't believe that unit testing eliminates debugging. I'll give a real > life example. Some TDD authors prevaricate and say "/virtually/ bug free". My emphasis. I prefer to prevaricate more accurately and usefully. TDD produces bug-resistant code, with reduced the odds of long bug hunts. The kind that typically require debugging and/or trace statements. > We had a bug where an update to our library disabled some features of a > client program. After some investigating, it was determined that the > client program was doing this: > > if (library_version == 3) > > instead of this: > > if (library_version >= 3) > > Our fix for this bug was to detect the client and report 3 for the version > if the client was the offending program, and otherwise report the true > version. TDD works in tiny steps. Upgrading a library is a big step (and another "legacy" situation). Fortunately, your tests let you roll back to the previous library version for frequent sanity checks (and emergency releases), until you debug the situation. > be approached in the test-first "no debugging" philosophy. There is no test-first "no debugging" philosophy. Test cases make an exquisite platform for debugging. For example, in VB[A] I use Debug.Assert in a test case, and failure raises the debugger. Then I move the current execution point back to the called method, step inside it, fix the code to pass the test, and resume running the remaining tests. Without TDD, this is the Unholiest of Unholies - programming in the debugger to generate spaghetti code. With TDD, it's nothing more than leveraging your tools effectively. When people use TDD, they generally report surprise that the incidences of _punitive_ debugging, with absolutely no other recourse, go way down. And some teams (in greenfield projects with user-level code) indeed never turn on their debugger, and code for years without it. -- Phlip http://www.greencheese.org/ZeekLand <-- NOT a blog!!! .