Question

I'm using NUnit for my unit tests and I have my unit test class library project setup so that Visual Studio launches the NUnit gui when I press F5. This lets me set breakpoints in my tests and look at the contents of variables, etc.

What isn't happening though is that if one of my tests crashes (throws an exception) Visual Studio does not automatically break on the line that caused the exception. The NUnit gui just shows that the test failed.

Since I'm using my tests to debug my code I would really like to break on exceptions as that would make things so much easier; especially when the code is in a loop and I can't easily use conditional breakpoints.

Is this just a simple setting that I'm missing?

Was it helpful?

Solution

Debug->Exceptions. Check "Thrown" for the class of exceptions that you want to break on (likely "Common Language Runtime Exceptions").

OTHER TIPS

Here's the thing: NUnit is catching the exceptions, so they're not uncaught exceptions.

If viable for your code, you might try to derive a class from Exception and throw that class in your code at places you're trying to debug, and set a breakpoint in the derived class.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top