Test Data Builder

An alternative to ObjectMother that uses the BuilderPattern to create objects in ProgrammerTests.

ObjectMother does not cope well with variability in the test data being created, except by allowing the user of the objects to modify them. That doesn't work if the ObjectMother creates ValueObjects (because ValueObjectsShouldBeImmutable).

The TestDataBuilder pattern allows tests to specify only those parts of the objects that need to vary and use sensible defaults for those that are not relevant to the test.

For a longer description, see: http://www.natpryce.com/articles/000714.html. This document links to techniques for using and building upon TestDataBuilders.

This article describes how MockObjects and TestDataBuilders work together: http://www.valuablecode.com/2009/03/are-you-using-mocks-when-you-should-be-using-test-data-builders/


View edit of September 29, 2011 or FindPage with title or text search