Using Builders for test objects

Last week, Nat Pryce shared some good thoughts (and code examples) on using Builders for test data creation. His comments on how an Object Mother can be painful to maintain really resonated with me and mirrors my own experience.

As he points out, using an Object Mother can really clean up test code, making tests much more readable and straightforward. The downside is that they can end up being brittle or many times the number of methods tends to explode, as minor differences are needed for different test scenarios.

Using Builders also cleans up test code, but can allow for differences in test data without the need for a new method for each scenario.

About Scott

believes software development is more about people than technology; believes in agile processes; software developer, engineer, designer, architect, or whatever they're calling us these days; enjoys discussing software design; working on a program to write other programs (but it hasn't written itself yet).
This entry was posted in Agile Processes. Bookmark the permalink.

2 Responses to Using Builders for test objects

  1. Pingback: refactr Blog Archive » Groovy Builders

  2. Pingback: The best Markup Builder I could build in Java at Stephans Blog

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>