什么是ObjectMother? [英] What is an ObjectMother?

查看:336
本文介绍了什么是ObjectMother?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

解决方案


ObjectMother以工厂模式开始,通过简单的方法调用提供预制的测试对象。它通过
超出工厂的范围,便于自定义创建的对象,
提供了在测试期间更新对象的方法,如果需要,则
,如果需要,从数据库中删除对象完成测试。



使用ObjectMother的一些原因:

*减少测试中的代码重复,提高测试的可维护性

*使测试对象超级 - 易于访问,鼓励开发人员编写更多的测试。

*每个测试都使用新的数据运行。

*测试总是自己清理。


http ://c2.com/cgi/wiki?ObjectMother


What is an ObjectMother and what are common usage scenarios for this pattern?

解决方案

ObjectMother starts with the factory pattern, by delivering prefabricated test-ready objects via a simple method call. It moves beyond the realm of the factory by facilitating the customization of created objects, providing methods to update the objects during the tests, and if necessary, deleting the object from the database at the completion of the test.

Some reasons to use ObjectMother:
* Reduce code duplication in tests, increasing test maintainability
* Make test objects super-easily accessible, encouraging developers to write more tests.
* Every test runs with fresh data.
* Tests always clean up after themselves.

(http://c2.com/cgi/wiki?ObjectMother)

这篇关于什么是ObjectMother?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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