每个主要的模拟框架在现实世界中的优缺点是什么? [英] What are the real-world pros and cons of each of the major mocking frameworks?

查看:13
本文介绍了每个主要的模拟框架在现实世界中的优缺点是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

另请参阅我应该考虑什么什么时候选择一个模拟框架.Net"

我正在尝试决定在我最近开始的 .NET 项目中使用的模拟框架.我想加快我对不同框架的研究.我最近阅读了这篇博文 http://codevanced.net/post/Mocking-frameworks-comparison.aspx 并想知道 StackOverflow 的任何观众是否有任何东西可以添加到框架的实际优势和警告中.

I'm trying to decide on a mocking framework to use on a .NET project I've recently embarked on. I'd like to speed my research on the different frameworks. I've recently read this blog post http://codevanced.net/post/Mocking-frameworks-comparison.aspx and wondered if any of the StackOverflow audience has anything to add in the way of real-world advantages and caveats to the frameworks.

人们能否列出他们当前使用的模拟框架的优点/缺点,或者他们已经研究过在 .NET 项目中自己使用的模拟框架的优缺点.我认为这不仅有助于我决定我当前的项目,而且还有助于其他人在为他们的情况选择正确的框架时做出更明智的决定.我不是任何框架的专家,但我想获得支持和反对我遇到的主要框架的论据:

Could people could list the pros/cons of the mocking frameworks they either currently use or have investigated for their own use on .NET projects. I think this would be not only a help to me to decide for my current project, but it will help others make more informed decisions when picking the correct framework for their situation. I'm not an expert on any of the frameworks but I would like to get arguments for and against the major frameworks I've come across:

  • RhinoMocks
  • 起订量
  • TypeMock 隔离器
  • NMock

以及我错过的其他可用替代品.我还想了解因问题而切换或停止使用产品的用户的见解.

And other usable alternatives that I've missed. I'd also like insights from users that have switched or stopped using products because of issues.

推荐答案

我根本不了解 Moles,但我会介绍一些我知道的(不过我真的需要一张桌子).

I don't know Moles at all, but I'll cover the ones I know a bit about (I really need a table for this, though).

起订量

优点

  • 类型安全
  • 一致的界面
  • 鼓励优秀的设计

缺点

  • 不像某些竞争对手那样功能齐全
    • 它不能模拟委托
    • 它不能满足有序的期望
    • 可能还有其他我现在想不到的事情......

    犀牛模拟

    优点

    • 类型安全
    • 完整的功能集
    • 鼓励优秀的设计

    缺点

    • 令人困惑的 API.有太多不同的方法可以做同样的事情,如果你以错误的方式将它们组合起来,那就行不通了.
    • 只能模拟接口和虚拟/抽象成员

    TypeMock 隔离器

    优点

    • 类型安全 (AFAIR)
    • 可以模拟任何东西

    缺点

    • 非常具有侵略性
    • 潜在供应商锁定
    • 不鼓励好的设计

    NMock

    优点

    • 鼓励优秀的设计
    • 适用于任何版本的 .NET(甚至 1.1)

    缺点

    • 不是类型安全的
    • 只能模拟接口和虚拟/抽象成员

    请注意,特别是关于 TypeMock 的优点和缺点是非常有争议的.我在我的博客上发表了我自己对此事的看法.

    Please note that particularly the advantages and disadvantages regarding TypeMock are highly controversial. I published my own take on the matter on my blog.

    我在 2003 年开始使用 NMock,当时它是唯一的选择,然后因为其类型安全性而迁移到 Rhino Mocks,现在因为 API 更简单而使用 Moq.

    I started out with NMock when that was the only option back in 2003, then migrated to Rhino Mocks because of its type safety, and now use Moq because of the simpler API.

    这篇关于每个主要的模拟框架在现实世界中的优缺点是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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