The World’s Leading Microsoft .NET Magazine
   
 
Derek's Blog of .NET Whining

.NET sycophant-at-large

Terror Alert Level

««
September 2008
»»
SM
T
WTFS
  123456
78910111213
14151617181920
21222324252627
282930
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

This blog is created and maintained by the author of the page and in no way associated with SYS-CON Media or .NET Developer's Journal. The author of the blog assumes all liability and responsibility personally for the content of the page.
www.blog-n-play.com is a registered trademark (78553120) of SYS-CON Media.