|
10:32:21 PM |
|
Time to plug NMock. It's a dynamic mock object library for .NET based on work Nat Pryce did in the Java MockObjects project.
It's one of those things that we wrote very quickly (completely test first, of course) in hardly any time at all. It was written last October and I've been using it on a number of projects (as have other people) with no problems - it just, like, works.
All you need to do is supply it with a class or interface that needs to be mocked and it will dynamically create a new class on the fly (by emitting .NET bytecode) that acts as a mock object. This mock can be setup with return values and expectations. Expectations can be simple things (such as equality checks) or custom constraints (such as a regular expression).
What's great is that a bug was found (well, an unimplemented feature) by Jeremy Stell-Smith last week. And he went about reporting it in the most ideal way possible. He supplied a failing unit test. So we added it to the suite and fixed it (with one line of code) and everything was green again. It took less than a minute to fix a bug I knew nothing about. In the words of Mr Stell-Smith - Sweeeeet.
Why can't all oss projects work like that?
Go look at a simple example
|