RhinoMock与TypeMock与NUnit的模拟? [英] RhinoMock vs. TypeMock vs. NUnit's Mocking?

查看:94
本文介绍了RhinoMock与TypeMock与NUnit的模拟?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始进行测试驱动开发,我想知道RhinoMock,TypeMock和NUnit的内置模拟之间的主要区别吗?

任何信息将不胜感激!

解决方案

TypeMock是一种商业产品(意味着您必须为此付费),但是可以模拟具体对象-与RhinoMocks/NUnit/MoQ不同,后者可以仅模拟接口/抽象类.它是如何达到临界黑魔法的,但是它在CLR上做了一些非常聪明的事情.

当您在项目中使用不使用许多接口的库时,这特别有用.因此,例如,您可以使用TypeMock模拟LINQtoSQL数据上下文或Sharepoint对象.但是,如果您使用的是TypeMock,这不是应用程序中不良设计的借口.

据我所知,除了语法上的微小差异外,大多数模拟框架都已脱离旧的记录/播放模型.通常,您可以通过使用Fluent接口编写期望值来设置模拟.

我个人只使用了起订量,而我<3.

I am just starting to do Test Driven Development, and I am wondering the major differences between RhinoMock, TypeMock, and NUnit's built-in mocking?

Any information would be greatly appreciated!

解决方案

TypeMock is a commercial product (meaning you'll have to pay for it) but will allow you to mock concrete objects - unlike RhinoMocks/NUnit/MoQ which can only mock an interface/abstract class. How it achieves this is borderline black magic, but it does some very clever things with the CLR.

This can be particularly useful when you use libraries in your project that don't use many interfaces. So you could, for example, use TypeMock to mock out a LINQtoSQL datacontext, or Sharepoint objects. However, if you are using TypeMock this is no excuse for bad design in your application.

As far as I'm aware, aside from minor syntax differences, most of the mocking frameworks have moved away from the old record/playback model. Commonly, you set up your mocks by writing expectations using a Fluent Interface.

Personally, I have only used MoQ and I <3 it.

这篇关于RhinoMock与TypeMock与NUnit的模拟?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆