Alex Rivera | Logout

Assert.DoesNotThrow with NUnit -- how to get stack trace?

Asked 2011-06-16T13:28:11.900
10

I am using NUnit for unit testing (running with TD.NET).

When using Assert.DoesNotThrow, i get the exception, but without any stack trace, which makes it harder to identify root issue.

How can i tackle this?

Edit
Report

1 Answer

3

I doubt it really answers your question, but I'd shorten the test to a single situation so that you don't need to wrap some code into a delegate that you pass to Assert.DoesNotThrow. Then, just write the test without any assertions. A test that throws an unexpected exception will fail, so it will do what you want, and you'll get the full exception.

About 10%-ish of my tests work like this; no assertions at all, and method names like ThisOrThatShouldNeverThrow().

Another option, while debugging, is to run the test in a debugger (using TD.Net) and in Debug|Exceptions check some additional boxes so that the debugger stops when the exception is thrown.

answered 2011-06-16T14:26:23.057

Your Answer