In particular, Typemock Isolator.
DISCLAIMER: I am in no way affiliated or receiving any compensation from the makers of Typemock. Simply a developer in the trenches loving this tool in his tool box. From thier website: http://www.typemock.com/index.php
|“Isolate any .NET dependencies to make unit testing easy” What does Isolator do?Typemock Isolator gives .NET developers the power to easily perform unit testing by making unit tests easy to write and automate.Isolator improves the bug-fix-time factor, and increases your code coverage.|
I’m not really going to review it, but it is an excellent product for use in writing unit tests. Plays 100% with NUnit. This is simply a no brainer, a tool you must have as a professional developer working with .NET.
If you are familiar with unit testing, then you have run into the "Mock” object. It looks and works just like the real thing, but it’s not, it’s a fake that does your bidding so you can control the outcomes of the tests to hit the proper scenarios for verification. And for small loosely coupled objects, this works with the added overhead of making the mock objects. But invariably you will end up with a data-bound object or a class sub-classed 3 levels deep and controlling the testing inputs gets harder and harder to control.
There are many development patterns out there that help to mitigate this “cost” such as factories with delegated constructors to allow snapping in of the data-provider, but these quickly become very complex beasts, and the codebase is just as large as the production code. Yes it works, yes it’s thorough, but is there a better way?
Yes! Why just today, I was creating some tests around a subsystem that essentially picks what will be shown to the user based on various rules. We are re-using the subsystem with another application and since the codebase is well set up and shared between like applications, with proper testing in place, we will be able to re-factor the code to be used in both spots with much higher confidence.
For one scenario, a random number between 0 and 99 is picked values less then 50 see A and the values greater then 50 see B. Well to right a test for this, you really need a consistent value returned from the random number generator. In my case, the random number was being returned from a private static little wrapper function around Random.GetNext() which I wil call GettRandomInt for namesake.
Typemock Isolater allowed me to intercept the call to GettRandomInt and force a return value of whatever I need for that test to be able to fully test my scenario. In a single line of code. That’s right 1 DAMN LINE OF CODE, I almost cried. Mind you I got lucky in that it was a static function so I never needed an instance, but at worse, 2 lines of code. Not too bad. And it was a private member as well. It has always been a source of frustration to only be able to test public functions, or to break ideal object model integrity for testing purposes alone. I mean of course quality is the clear choice here, but it isn’t free.
I was just very impressed with the product through a single day’s use. If you have ever “mocked autoquote” (and you know who you are (-: ) I guarantee, that’s right I said it, GUARANTEE, your satisfaction! I will be buying the personal edition for myself to use on my own projects, and for $89.00 that’s quite affordable.
They also have SharePoint isolator which I have not used, but have worked with SharePoint. And I can only imagine how this would be an essential tool.
Anyway, thank you Rob Witt for showing me the light. Amazing!