Debugging Unit tests using the VS.net debugger

My blog has moved.
You can view this post at the following address:
http://www.osherove.com/blog/2004/1/9/debugging-unit-tests-using-the-vsnet-debugger.html
Published Friday, January 09, 2004 5:12 PM by RoyOsherove

Comments

Friday, January 09, 2004 12:46 PM by Jim Arnold

# re: Debugging Unit tests using the VS.net debugger

Or install NUnit AddIn, right click and Test with Debugger. I know there are some lurking bugs, but I find it much much easier than flipping to the NUnit GUI.

Jim
Friday, January 09, 2004 12:49 PM by Roy Osherove

# re: Debugging Unit tests using the VS.net debugger

Jim: That's a good solution too, but the problem is that , plenty of times, a test will be run after the [setup] method, and might expect some initialized state in private objects of the test fixure.
When you debug using the NUnit Addin, you don't get that. The Setup method never runs, only the method you are currently in runs, which might not give you enough context to debug against.
Friday, January 09, 2004 2:01 PM by Udi Dahan - The Software Simplist

# re: Debugging Unit tests using the VS.net debugger

Roy,

I use the NUnit Addin extensively and I've never run into a case when a test ( obviously marked with a [test] attribute ) runs without the corresponding setup being run first when run in the context of a test.

But, if you call a method (A) marked by [test] from a different test method (B) that is currently being run ( not a good idea from my experience ) then before the call to A, the setup won't run.

Anyway, hope you're enjoying yourself over there in Norway.
Friday, January 09, 2004 2:10 PM by Roy Osherove

# re: Debugging Unit tests using the VS.net debugger

Hrm. Well gee. I guess I only now found out. For some reason I always figured that the "Test with Debugger" only ran the active procedure without actually running the setup procedure first. Looks like I'm mistaken. huh.