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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The
Assert.DoesNotThrowis redundant, if a tests throws the test will fail automatically without an assert. To clarify what is being tested is, in my humble opinion, better conveyed in the test method name. There is very little documentation benefit in theAssert.DoesNotThrowsyntax and, as you point out, just makes it harder to fix failing tests.Also, if you have a very long test with multiple asserts the
Assert.DoesNotThrowfills an important role as to assert that the correct code block threw an exception. However, in this case a more suitable solution is to see if the test can be shortened and/or asserts moved into their own tests.