有人可以提供存根和驱动程序的实际示例吗?
我需要一些关于自上而下和自下而上的测试方法的存根和驱动程序的实际示例。我这里不需要代码。只是基于场景的示例。
I need some practical examples of stubs and drivers with respect to top-down and bottom-up approaches to testing. I don't require code here. Just the scenario based examples.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
驱动程序是一组测试类的接口(方法、属性、构造函数等)的测试。
存根是一个假对象,充当数据库或记录器等其他功能的替代品。
模拟是一个带有断言的假对象。
以下是使用模拟对象的测试示例。如果你取出断言,它就变成了一个存根。总的来说,这些类型的测试是驱动程序,因为它们运用对象的方法和属性。
这是示例:
http://www. zorched.net/2007/03/10/mocking-net-objects-with-nunit/
A driver is a set of tests that test the interface of your class (methods, properties, constructor, etc).
A stub is a fake object that acts as a stand-in for other functionality like a database or a logger.
A mock is a fake object that has asserts in it.
Following is an example of a test using a mock object. If you take out the asserts, it becomes a stub. Collectively, these kinds of tests are drivers, because they exercise the methods and properties of your object.
Here is the example:
http://www.zorched.net/2007/03/10/mocking-net-objects-with-nunit/