Our use of Moq in the reference implementation

Coordinator
Jul 21, 2009 at 1:58 AM

Up until just a few of iterations ago, we were writing all of our fakes/doubles by hand. When provided the option of using Moq, we jumped at the chance and it's made a fairly significant impact on the amount of time it takes us to write the unit tests. With that said, we want to hear your thoughts on the matter.

* Are you okay with us using Moq?
* Is it clear the how we're using it? +
* If you're using a mocking framework, which one?

+ To see an example of how we're using Moq, check out Tests/Unit/WWPlatform.Web.Tests/Controllers/CustomerControllerTest.cs in the solution.

Thanks.

Oct 12, 2009 at 10:20 AM

How did you select MOQ as a mocking framework?

Did you evaluate other possiblities like Rhino Mocks?

Kind Regards,

Patrick

 

Oct 14, 2009 at 6:19 PM

For us, deciding upon Moq was a fairly easy choice to make.  There were a few things that were considered:

  • The API is fairly simple
  • After a spike (read experiment) we decided that using Moq allowed us to speed development and have readable tests
  • After the experiment, it only took a couple of hours to get the team up to speed with the technology
  • Our legal department did not object to the license
  • There was already precedent of using Moq within MS
  • I knew we could get support from the Moq dev team if needed (we did and they were very helpful)

For us, the license and the precedent of other MS teams using Moq really steered the decision, due to the constraints that we work under.  Without those two factors, we probably would have continued hand-writing mocks/fakes/stubs.

If you are looking at mocking frameworks, your team may have other considerations or constraints that you need to identify and figure out. 

I hope that helps,

Michael Puleio -- patterns & practices
http://blogs.msdn.com/mpuleio