mattaddy / SObjectFabricator

An SObject fabrication API to reduce database interactions and dependencies on triggers in Apex unit tests.
Other
89 stars 14 forks source link

Enhancement: Allow fixtures of parent objects in constructor #6

Open cropredyHelix opened 7 years ago

cropredyHelix commented 7 years ago

Currently, you can construct a sfab_FabricatedSObject these ways:

It would be useful in constructing fixtures of SObjects to also support:

new sfab_FabricatedSObject(
       Type xxx.class, 
       map<SObjectField,Object> valuesByFieldToken,
       map<String,sFab_FabricatedSObject> fabricatedParentsByRelationshipName);

A common use case is to have a fixture of "default" SObject where such default includes default parents. For example, a default Opportunity with a default Account.

BTW; we've installed this package in our org and love it! Replaces an earlier home grown library that used similar JSON technique but wasn't as expressive.

mattaddy commented 6 years ago

@cropredyHelix Thanks for the suggestion! I'll take a look more this week.

I'm glad to hear that you've found the package useful!