Skip to content
Java Design Patterns
Main Navigation
设计模式
编程原则
代码片段
Appearance
Return to top
On this page
Object Mother
使用分隔的构建器和工厂接口定义不可变内容的工厂。
Class diagram
Applicability
Use the Object Mother pattern when
您需要在多个测试中使用一致的对象
您希望减少用于在测试中创建对象的代码
每个测试都应该使用新数据运行
Credits
Answer by David Brown
to the stackoverflow question:
What is an ObjectMother?
c2wiki - Object Mother
Nat Pryce - Test Data Builders: an alternative to the Object Mother pattern