Tuesday, October 19, 2010

unit testing void methods

Assert class does not allow us to test void methods. So the work around would be to throw Exceptions from the void method, and handle it in your test class.

NUnit.Framework provides a method level attibute - ExpectedException for handling exceptions in your test class.


Reference: http://www.nunit.org/index.php?p=exception&r=2.2.10