Jesse has written a great blog post on using test builders to improve the expressiveness of unit tests. He has convinced me that builders are useful and that they provide an easy way to construct objects that are in a valid state. Testing can be hard; I find defining a method for each of the object’s properties to be tedious and repetitive. This is especially problematic if you’re working with an object with dozens of properties.
To balance expressive with conciseness, I’ve refactored the builder to use Python dictionaries
I find this code to be just as expressive, easier to use and most importantly not repetitive.