Pages

Tuesday, January 13, 2009

NMock

NMock: A Dynamic Mock Object Library for .NET

NMock is a framework for .Net that allows creation of mock and stub objects in Test Driven Development using Microsoft .Net Framework.
The documentation is enhanced and there is a tutorial explaining the concepts. This framework is a necessary addition to Unit Testing framework as it allows to isolate the unit being tested. The external dependencies are replaced with mock/stub objects and provide the expected output. That way, if your class retrieves data from a database and the test depends on it, stub object can be created that fits the expectations. The class will receive what it expects and it will get tested properly. The test will not fail for reasons outside the tested unit, for example - not running database server, or wrong data in the database, etc. This is, of course, unless you are doing some database tests. :)

Quickstart and Tutorial available on the site.

No comments: