|
Derek's Blog of .NET Whining | |
|
Login Console Mailing List
|
Oh yeah? Well, mock you!
I am a big advocate of unit testing. The big fly-in-the-ointment for me, though, is that there are so, so many situations that are difficult to unit test, because they involve external resource integration -- databases, Active Directories, etc., etc.. Of course, the answer to this is the creation of mock objects, but there are two problems with this, in my book. First, a mock object is not the real thing and, to the extent that you aren't testing against the real thing, you are introducing into your tests the possibility of not really testing what you think you are testing. The second thing -- which I saw a lot of at my previous employer -- is that hours and hours can be wasted creating mock interfaces for tests, rather than actually creating productive code. To address the second of these issues, some folks have created an automatic mock object library thingy for .NET called nMock. The link is http://www.nmock.org/ and I strongly encourage you to check it out. Here are some good links (thanks to Magenic's Steve Baker) on using nMock... http://vaderpi.scottandlaurie.com/blog/?p=185 http://www.todyruik.com/files/NMock2QuickReference.pdf http://weblogs.asp.net/rosherove/archive/2005/06/18/413577.aspx http://cvs.sourceforge.net/viewcvs.py/*checkout*/nmock/nmock2/src/NMock2.AcceptanceTests/Example.cs |