Debugging with NUnit

I use NUnit for my unit tests, and I have a unit test class library project project, so Visual Studio starts NUnit gui when I press F5. This allows me to set breakpoints in my tests and see the contents of variables, etc.

What does not happen is that if one of my tests fails (throws an exception), Visual Studio does not automatically break the line that caused the exception. NUnit gui just shows that the test failed.

Since I use my tests to debug my code, I would really like to deal with exceptions, as this will simplify the situation; especially when the code is in a loop, and I cannot easily use conditional breakpoints.

Is this just a simple setup that I am missing?

+4
source share
2 answers

Debug-> Exceptions. Check the "Abandoned" check box for the class of exceptions that you want to break (probably, "Exceptions for the regular Runtime language").

+4
source

Here's what: NUnit catches exceptions, so they are not uncaught exceptions.

If you are viable for your code, you can try to get the class from Exception and throw that class in your code in the places you are trying to debug, and set a breakpoint in the derived class.

+1
source

Source: https://habr.com/ru/post/1286586/


All Articles