Object mother
An object mother is a test-data creation pattern that provides reusable methods or objects for constructing valid, preconfigured test fixtures.
Effective Behavior-Driven Development
A test-data construction pattern that provides methods for creating default objects or object hierarchies customized for particular tests.
- How it is used
- Creates customized default objects and hierarchies for scenario test data while keeping incidental details out of scenario descriptions.
- How deep it goes
- Works through an optional-parameter method and a separate order builder, while declining a one-size-fits-all interface design.
- Examples
- Uses pizza items with selected names or sizes and orders with one default item or multiple customized items.
- What you can do after
- Build it from scratch as a small customization method or an order builder that returns scenario-ready test data.
Read how Effective Behavior-Driven Development explains object mother →
Test Driven: Practical TDD and Acceptance TDD for Java Developers
A test-support pattern in which an object or set of objects provides complete, valid domain objects and supports their customization and lifecycle management.
- How it is used
- Centralizes test-object creation methods to reduce duplicated fixture setup across test classes.
- How deep it goes
- Defines a sophisticated factory through object completeness, lifecycle access, customization, updates, and cleanup.
- Examples
- Uses Person fixtures for Alice, Billy, and Clark, including a relationship between Alice and Billy.
- What you can do after
- Build it from scratch by gathering fixture creation methods in a helper that supplies and manages valid domain objects.
Read how Test Driven: Practical TDD and Acceptance TDD for Java Developers explains object mother →
Also covered in
- Data-Oriented Programming in JavaIn early access (MEAP)
Related concepts
- A Pattern Languagepart of · A pattern language is a structured collection of interrelated patterns that describes recurring problems and their relationships within a domain.
- entityproduces · An entity is a distinct, identifiable object, concept, participant, or record represented in a system's model or data.
- fluent interfaceuses · A fluent interface is an API design style in which operations return objects or values that enable readable chaining of subsequent calls.
- test fixtureproduces · A test fixture is prepared data, state, resources, or setup that establishes controlled conditions for one or more tests, sometimes including cleanup.
- personauses · A persona is a characterization or assumed identity of a user, person, or software agent, defined by relevant traits, goals, perspectives, expertise, or behaviors.
Questions about object mother
What is object mother?
An object mother is a test-data creation pattern that provides reusable methods or objects for constructing valid, preconfigured test fixtures.
Which Manning books explain object mother?
Effective Behavior-Driven Development and Test Driven: Practical TDD and Acceptance TDD for Java Developers.
What should I know before learning object mother?
Manning books that teach object mother usually introduce application code first.
What is object mother part of?
Object mother is part of A Pattern Language. A pattern language is a structured collection of interrelated patterns that describes recurring problems and their relationships within a domain.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

