I use the Fixture Factories all the time. A lot of my data is quite hierarchically nested, with hasMany relations, and I need to make deeply nested collections of records, like an A with 6 B’s, each of which have 1 or 2 C’s, which all have a D. Trying to set all of that up with arrays of data gets tedious, especially when most of the C data is replicated for a given test, but different for different tests, so default data isn’t the solution.
I have created a number of scenarios that help, with parameters passed to tell them how do to all of this. I am finding some situations where they get quite complicated, and it feels that this structure falls a bit short from a design and usability perspective.
I’ve been thinking about creating a scenario that returns an object (maybe the scenario, maybe some other test-specific service class) with chainable methods that could add the deep-level data, sort of mini-scenarios if you will. Anybody done something like this and have pointers of how to proceed, or pitfalls to avoid? Am I over-engineering this, and should just make the mini-scenarios directly instead of hiding them away behind interfaces? Any other thoughts, apart from “simplify your data”? ![]()