RhinoMock:蒙版与StrictMocks与DynamicMocks [英] RhinoMock : Mocks Vs StrictMocks Vs DynamicMocks

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

问题描述

我了解Mock和Stub之间的区别.

I understand the difference between a Mock and a Stub.

但是RhinoMock框架中不同类型的Mocks令我感到困惑.

But different types of Mocks in RhinoMock framework confuses me.

有人可以用RhinoMock框架解释Mocks VS StrictMocks VS DynamicMocks的概念.

Could someone explain the concepts of Mocks Vs StrictMocks Vs DynamicMocks in terms of RhinoMock framework.

非常感谢您的回答.

推荐答案

严格模拟是一种模拟,如果您尝试使用任何未明确设置为要使用的方法,都会抛出异常.

A strict mock is a mock that will throw an exception if you try to use any method that has not explicitly been set up to be used.

如果尝试使用未设置的方法,则动态(或松散)模拟将不会引发异常,它只会从方法中返回默认值 null 并继续执行.

A dynamic (or loose) mock will not throw an exception if you try to use a method that is not set up, it will simply return null a default value from the method and keep going.

强烈建议使用动态模拟,因为严格的模拟通常会成为维护的噩梦. 这是一篇不错的博客文章,其中包含代码示例严格与动态的关系,以及为什么严格的模拟通常不是一个好主意.

It is highly recommended to use dynamic mocks, as strict mocks generally turn out to be a maintenance nightmare. Here's a good blog post that has a code example of strict vs. dynamic, and why strict mocks are usually a bad idea.

这篇关于RhinoMock:蒙版与StrictMocks与DynamicMocks的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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