chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
Hi,

I want to use type mock for testing our Legacy application that runs on top of Sharepoint, and to me TypeMock seems to be the best option. However we also have the option of using Microsoft Fakes as all of us devs have VS Premium license. I want to know what are the advantages of using TypeMock over Microsoft Fakes rather than just readability? I need concrete reasoning so that I can convince my higher management to buy TM license :)

Regards,
asked by syed_afraz_ali (660 points)

2 Answers

0 votes
Hi,

Don't take our word for it. See what other people are saying. :D
answered by alex (17k points)
+1 vote
I did come up with some difference and thought I should just post them here for a future reference for anyone else.

Generating Fakes
With Microsoft Fakes you need to manually generate the fakes for each assembly, for example let’s say you want to generate a Fake for DateTime then you need to add a reference of System.dll. Right click the DLL and select Generate Fake. Then use the faked items in your test.

TypeMock allows its users to fake any assembly, class or instance without generating a fake assembly. TypeMock intercepts the CLR calls for that assembly at run time and re-directs to its fakes thus there is no need to generate a fake assembly.

Mocking
In Microsoft Fakes, there is no mocking built-in into the framework i.e. there is no built-in way to test whether a method was called. This however can be achieved by manually adding specific code inside the stubbed method like some Boolean condition to verify that the method was called.

TypeMock allows easy mocking and method verification like the rest of the mocking frameworks. This increases the readability of the tests.

Object Names
With Microsoft Fake you need to use the objects in the generated faked assembly. What this means is that if you wanted to fake DateTime.Now, you will have to ShimDateTime.NowGet. Notice how we are actually using different object and property to fake DateTime.Now.

TypeMock actually intercepts the calls to the classes at CLR level thus it does not rely on generating fake assemblies and allows the user to fake anything. In the DateTime.Now scenario the TypeMock fake will look like the following:


Code Readability
One of the most important aspects of unit tests is that they should be clean and easy to understand. MS Fake add their own complexity to the unit tests as you have to create and dispose all fakes (called Shims in MS Fake).

TypeMock isolator sits at the CLR level and thus in the test we fake out any class using the standard methods provided by all the famous mocking frameworks. This makes the test cases, short, precise, clean and easy to maintain.

Maintenance
With Microsoft Fakes the test are based on generated code. That is to say, a phase of code generation is necessary to create the “stubs” which increases the maintenance.

TypeMock provided the same fake mechanism as the rest of mocking tools in the industry and you don’t need to generate any code for your fakes/stubs.
answered by syed_afraz_ali (660 points)
...