A Short Look at Debugging Under NUnit


My standard way of using NUnit is in its stand-alone GUI form. The NUnit GUI runs as a separate program that is looking at your program. When you press the button, NUnit runs your tests and displays the results in its panes. My usual work cycle is to write or enhance a test, make it work, run the tests, and repeat. The cycle, for me, is quite short: usually less than ten minutes, often only two.

Working this way, I really dont get many bugs and I dont often get confused . Thats good, because I dont like hunting for bugs and I dont like being confused. Both slow me down. Sometimes, though, its hard to write a test for something. Often this happens when Im using some .NET object that Im not familiar with and I dont know what kind of result its going to give me back.

My first reaction is often to do a Console.WriteLine to see what is going on. NUnit displays the console output right in one of its panes, and I build my softwareeven forms softwarein console mode, so this works pretty well. But it has its limitations, as well see.

Now of course Visual Studio has strong debugging capabilities, and you can set breakpoints, run your program, stop at the breakpoints, and look around. You can inspect variables , step the program, and so on. Its all good. Sometimes in working with the XML Notepad, Ive done that to figure out what was going on. But I always lean away from using the debugger. For me, it is a potential trap, a slippery slope. All too many times in the past, I have written vast amounts of code and then spent hours in the debugger trying to make it work. The test-driven style I use now, which youre seeing in this book, allows me to work at a more constant rate of progress, without those long, frustrating, high-pressure debugging sessions. Im afraid that if I get too good at using the debugger, I might fall back into bad habits. So Ive held off on learning to use debuggers . Ive been programming in Ruby for two years or more, dont know how to use its debugger at all, and dont miss it a bit. Still, Visual Studios debugger can be helpful at times, and you can use it a few ways in conjunction with NUnit. Lets look at a couple of them.




Extreme Programming Adventures in C#
Javaв„ў EE 5 Tutorial, The (3rd Edition)
ISBN: 735619492
EAN: 2147483647
Year: 2006
Pages: 291

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net