Question

I did search the forum and did not find a similar question. I'm looking to make a final decision on our mocking framework of choice moving forward as a best practice - I've decided on Moq... untill I just recently discovered MS has finally created a mocking framework called Moles which seems to work similar to TypeMock via the profiler API sexyness etc..

There's a million 'NMock vs Moq vs TypeMock vs Rhino....' threads on here. But I never see Moles involved.In fact, I did not even know if its existence until a short time ago. Anyone using it? In Production? Anyone dump their old mocking framework for it, and if so, which one? How did it compare to ther mocking frameworks you've used?

thanks.. ps, we are using VS2008 and are moving to 2010 shortly.

Was it helpful?

Solution

I am in the same scenario you are in , so I'd like to comment on my experiences.

Both Typemock and Moles have the goal of isolation in mind. Especially for those pesky sealed classes, non-virtual methods.

I believe an isolation framework, as ones mentioned above, are needed especially if you are in the later phases of development and/or have no/little control of the code base.

These are the advantages in Typemock, I have not yet discovered with Moles

  • Support for code coverage tools ( Ncover and Partcover )
  • Support to intercept/verify on privates (methods / properties) [yes this is controversial]
  • More polished product, up and running fast with intuitive API (still messing with Moles to even work right)

I hope Moles matures into released product, but the beginning of my tinkering with it seems to be no different than other MS Research projects; usually unpolished, but that seems to be the nature of those type of projects.

OTHER TIPS

I think moles are taking mocking to the next level, it's much more powerful.

What do you mean by 'in production'?. Moles are only useful in unit testing. It has a serious performance impact and it also allows unsafe code in production (ever thought about replacing an IsAuthorized function to return true?).

Moles are usable in both 2008 and 2009.

Hope this answers your question.

Moles is used internally at Microsoft by several product teams.

Well, may be ,there are few threading issues which seem to crop in between, its very difficult to repro. It basically crashes VS 2010 when you even try to put a breakpoint in attached process. It did happen few times for me not only on just one machine but later dissappeared for unknown reason.

As the detour happens debugging is a dance between your code and detour which might be difficult to cope up with initially and if there is exception during such then its just difficult to break on the exception.

The auto generated tests and PUTs- its diificult to grasp what message they are trying to convey i.e. should the coding pattern be changed or something else as although it tries to generate parameterised test based on interface but depending on the class under test, auuto gen PUTs might not be the best way leverage parameterised tests.

Overall, there is a learning curve plus the framework will also take some time to mature. Positive side, concept is good and maintaince cost ( if implemented correctly ) and the response time from the team supporting PEX is really positive, sometimes you get helpful answer within 2 hrs on the PEX forum.

Best Regards Yogesh Pawar

Moles and Pex is paradigm shift !! its too much to expect from a free frameowrk. So far I have not come across any reason not to use it unless you have cross technology code base but as long as it .net I moles and Pex is definitely The Answer !!

If by "in production" you mean using it on a product that is being used in production then absolutely!

We are using Moles to isolate functionality in our unit tests on a very high profile project for such companies as Google and McDonalds. Of course, unit tests are not run on the production server so Moles is never deployed to production.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top