Skip to content

Object Mother

使用分隔的构建器和工厂接口定义不可变内容的工厂。

Class diagram

alt text

Applicability

Use the Object Mother pattern when

  • 您需要在多个测试中使用一致的对象
  • 您希望减少用于在测试中创建对象的代码
  • 每个测试都应该使用新数据运行

Credits