I would not put extra Try / Catch sentences in Unit Tests. First of all, the expected exception in the unit test will already throw a Failure error. This is the default behavior of NUnit. In essence, a test harness wraps every call to your test functions with this code. Also, just using e.ToString () to show what happened, I believe that you are losing a lot of information. By default, I believe that NUnit will display not only the type of exception, but also the call stack, which I don’t think you see with your method.
Secondly, there are times when it is necessary. For example, you can use the [ExpectedException] attribute to actually tell when this will happen. Just make sure that when testing Asserts related to exceptions (e.g. Asserting count count> 0, etc.) you put a good description as an argument to assert. This is useful.
Everything else is not required at all. If the tests of your device are so large that you start to write WriteLines with what “step” of the test you are in, this is usually a sign that your test should really be broken down into several smaller tests. In other words, you are not performing a unit test, but rather an integration test.
source share