This is a brilliant article that I have been using all last month on my work projects and it is both immensely powerful and very practical. It has made testing much easier and saved a phenomenal amount of time. However Nat doesn’t quite explain fully why it is so brilliant. What I have found is that once I have configured a Builder then actually I tend to use the same base object with minor alterations. If I am testing a sales catalogue for example and I want to have a test chocolate bar, then chances are I actually want three or four of them, all pretty much identical except for an id code and name. Using this technique makes it a doodle to knock out several objects in as many lines.
When I started I was conscientious about trying to provide a readable and complete API, later I realised “why bother?”. You need to find some sensible defaults for the necessary fields in the object but once you have you only need to implement the API surrounding the testing you are doing. Once you realise that then you get faster again. A lot of my work involves refactoring an old application and I am constantly surprised how few fields are actually used in the various beans and value objects. Often if you supply the “key” fields (the uid and anything else unique) then nothing else matters.