I’m more and more convinced that Object Mothers are the way to go to manage test data. I owe my introduction to this pattern to David Goudreau.
A few users and items in fixture data so that you can start up your application and test without adding things from the UI… and then let your tests be self-sufficient: make an Object Mother that generates objects for you with sensible defaults. Instead of relying on fixtures, you know you have an object that nobody else will change. Excellent for reducing test fragility.
It can make builds a bit slower, but the test robustness is worth the tradeoff to me.
I’m busy adding it to my Selenium Tests today and basking in test robustness.
This could be seen as blog-pimping or link-spamming or whatever, but I think you might well be genuinely interested in reading about ["Object Daddy"](http://b.logi.cx/2007/11/26/object-daddy). (Be prepared. It’s a long post.)
December 14, 2007 at 3:39 am
Thanks, Yossef, looks interesting.
December 14, 2007 at 12:48 pm
Object Mother still has a fixture aspect to it. From Martin Fowler’s entry:
> “At this point it makes sense to have a factory object that can return standard fixtures. Maybe ‘John’, an employee who just got hired last week; ‘Heather’ and employee who’s been around for a decade.”
I think this differs a little bit from a [plain factory approach](http://www.dcmanges.com/blog/38) that provides reasonable defaults.
December 15, 2007 at 4:36 pm
Although, it does seem like Object Mother has become a subjective term. From xUnit Patterns:
> “Because there is no single, crisp definition of what someone means when they say “Object Mother”, it is advisable to refer to the individual patterns (such as Automated Teardown) when referring to specific capabilities of the Object Mother”
December 15, 2007 at 5:37 pm