I like to use free builders for the tested object to express the character of the object that I create. ObjectMothers tend to become bulky and tend (in the implementations I came across) to ultimately hide the details of creating objects.
For comparison:
User fred = CreateUser("fred").WithReputation(900) .WithScholarBadge() .WithCriticBadge()
vs
User fred = UserObjectMother.Fred()
To express the idea that the user has a reputation of 900, and these two specific icons will be incompatible with ObjectMother. The trend I saw is the developers, who then find this method, which builds Fred() , which is close to what they need so that they add more attributes to the object. A free builder, on the other hand, is expressive of what is being built, and it is easy to create specific users for testing as needed.
However, I also use these patterns exclusively in test code, since production code usually does not require such expressiveness.
source share