NMock - Dynamic Mock-Object Library for .NET - Verify Objects Interact Correctly From Unit Tests

If you do a lot of Unit Testing with NUnit or other test runners, you may be interested in NMock to create Mock Objects to represent custom objects.

As described on the website, a Mock:

  • takes on the interface of another object, allowing it to be substituted for a real one for testing purposes.
  • allows Expectations to be setup, specifying how the class under test is expected to interact with the mock.
  • fails the test if any of the expectations are violated.
  • can also act as a stub, allowing the test to specify objects to be returned from mocked methods.

I haven't tried this myself yet, but I can definitely see this being useful in testing certain areas of my current project that deal with a resource intensive custom object.  Rather than dealing with the custom object directly, it sounds like a Mock Object would be much better.

Check out NMock
here.

posted on Tuesday, August 17, 2004 5:55 AM

Main

David Hayden Google +

David Hayden Twitter

Health & Fitness

JavaScript Patterns Book Review

HTML 5 and CSS3 - Develop with Tomorrow's Standards Today

Professional ASP.NET Design Patterns Book Review

Beginning Mac Programming Book Review

C# in Depth Book Review

ASP.NET MVC

Orchard CMS

Categories