Anyone using Moles / Pex in production?
Asked Answered
O

6

11

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.

Overabundance answered 16/3, 2010 at 15:21 Comment(2)
my opinion was that Moles isn't just a mocking framework. It's more of an interceptor - what I didn't like about Moles: it generates more code. It's more of duct tape - doesn't lead you to clean up your design. e.g. Just Mole DateTime.Now already! doesn't cause you to put the responsibility behind a Clock role. On the other hand, Moles might be a easy option if you're dealing with an existing pile of legacy code.Treva
Moles has been replaced with Fakes msdn.microsoft.com/en-us/library/hh549175(v=vs.110).aspx in visual studio 2012Exonerate
E
7

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.

Etheleneethelin answered 20/4, 2010 at 16:41 Comment(0)
H
7

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.

Human answered 1/4, 2010 at 19:43 Comment(1)
thanks. I mean in writting production code using TDD using Moles when I wrote 'Production'Overabundance
E
7

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.

Etheleneethelin answered 20/4, 2010 at 16:41 Comment(0)
W
7

Moles is used internally at Microsoft by several product teams.

Weakwilled answered 23/4, 2010 at 9:30 Comment(0)
C
1

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 !!

Crashland answered 19/7, 2010 at 21:25 Comment(0)
C
1

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

Crashland answered 6/9, 2010 at 22:12 Comment(0)
C
0

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.

Carsick answered 24/2, 2012 at 16:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.