I just came across the ObjectMother pattern for creating a factory object to provide all sorts of test objects for unit testing. Essentially you create a class or classes with lots of nice static methods that return already setup objects for testing. This is especially helpful on larger projects where you have a lot of code that gets into each
1
|
setUp()
|
method. I’ll probably try it out on some of my home projects before I try to sell anyone on my team with using it.
Interestingly enough most of the blog entries that come up high when you google for ‘ObjectMother’ are for .NET developer blogs. I don’t know if that says anything about the pattern or not.