术语“模拟"的含义是什么?在C#中? [英] What is the meaning of the term "Mocking" in C#?

查看:111
本文介绍了术语“模拟"的含义是什么?在C#中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

C#/WPF上下文中,模拟是什么意思?

解决方案

在单元测试的上下文中,模拟提供了一种虚假的实现,该类型的实现与您的被测代码可以交互.

请参见 http://en.wikipedia.org/wiki/Mock_object

Roy Osherove的单元测试的艺术" 有很好的解释,我建议您阅读从C#中的单元测试开始

模拟与存根的不同之处在于,它可以与被测代码进行交互验证.存根仅返回预定义的值以帮助对代码进行单元测试.

What does the term mocking mean in the context of C#/WPF?

解决方案

In the context of unit testing, mocking is providing a fake implementation of a type that your code under test interacts with.

See http://en.wikipedia.org/wiki/Mock_object

The book "The Art of Unit Testing" by Roy Osherove has good explanations and I recommend it if you are getting started with unit testing in C#

A mock differs from a stub in that it verifies the interaction with your code under test. A stub simply returns pre-defined values to help unit test your code.

这篇关于术语“模拟"的含义是什么?在C#中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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