Monday, 26 April 2010

JustMock – New Mocking Framework

The world of unit testing in .NET has recently become just a little more interesting. This month Telerik has announced the beta of their new JustMock mocking framework.

The interesting thing about this framework, is that for the first time a new tool is actually trying to compete with the power of TypeMock’s Isolator framework.

JustMock, like Isolator, is using the CLR profiler API in order to intercept method calls, allowing mocking of virtually any kind of class/method in your code. Including static methods, private methods, sealed classes and more.

At a first glance JustMock API looks very similar to the AAA syntax of the Isolator tool, what I did notice howeverare two main differances:

  1. It appears that JustMock has two modes of operation. The standard mode, in which the profiler is not enabled, allowing mocking only ‘overridable’ methods and an advance mode in which the profiler is used and every “feature’ of the tool is turned on. On the upside disabling the profiler should yield better performance, however once you decide to use any of the advance methods (even in a single test) the profiler is turned on for everything. I suspect that the actual reason for this lies in the old Design For Testability debate in which many states that using such a powerful tool might cause a degraded design. giving this two modes of operation allow everyone to choose whether he wants to allow advanced usage of the tool or to enforce a more rigid design strategy.
  2. A quick comparison of the beta version abilities to that of the Isolator framework. shows that at this point JustMock is in its initial stages and is lacking many of the Isolator capability. However, according to its documentation, the most desired ability to mock classes from mscrolib.dll is fully supported. This means that finally we can mock out things like the file system, the system clock all kinds of collections and more.

Whet is left to be seen, is how long will it take Telerik to close the gap between their beta version to a mature release which can actually compete with other mocking frameworks out there. And of course what will be the pricing of this framework (nope its not going to be open sourced or free).

On my side I’m very happy to see more tool options out there, believing that the resulting competition will benefit all of us. Also i plan on diving deeper into JustMock getting a better understanding on its actual usage and limitations.


Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Walgreens Printable Coupons