Open cropredyHelix opened 7 years ago
Thanks for all the suggestions!
Again, thanks for all the suggestions! Feel free to submit a pull request for any of these recommendations, otherwise I'll likely implement them very soon.
Matt. I appreciate the response.
The way around this is to use the fflib pattern, unit of work layer, and Apex Mocks. Andy Fawcett's second edition Force.com Enterprise Architecture has a chapter on this.
Most apex code ultimately does DML so blending (in the readme) how to execute DML on fabricated objects would be useful to the user of your lib.
Bottom line, whereas you are an advanced developer, getting tradition-bound apex devs to use your excellent lib requires a few more examples.
Once you commit a new version with prefixes, I know I'll be adding it to our org!
@cropredyHelix I merged #3 which addresses the prefix suggestion.
cool - this should increase adoption. The more you tie this into the fflib pattern via the readme, the more likely you can get andyinthecould to feature you as a guest blogger which will increase the number of users of this fine fabrication framework - as I noted earlier, the more than 2 levels for child relationships is really great!
On Sun, Aug 27, 2017 at 11:15 AM, Matt Addy notifications@github.com wrote:
@cropredyHelix https://github.com/cropredyhelix I merged #3 https://github.com/mattaddy/SObjectFabricator/pull/3 which addresses the prefix suggestion.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mattaddy/SObjectFabricator/issues/2#issuecomment-325214978, or mute the thread https://github.com/notifications/unsubscribe-auth/AYdgA_RzJkvR6eGUm_LTviTD8ehwO21lks5scbI-gaJpZM4O8DHt .
-- Eric Kintzer Salesforce Architect 1 Circle Star Way, Floor 2, San Carlos, CA 94070 650 533 5619 (m) www.helix.com | We're hiring https://www.helix.com/careers
We've loved using this and I agree, more than 2 levels for child relationships is amazing! We use this along with the fflib pattern and they have a class called fflib_IDGenerator that we use to generate an ID for whatever object we are fabricating. Used with the Mocking as mentioned above makes testings much faster!
I like where you are going here and might make a couple of suggestions
fflib
class naming convention and prefix all these classes withsfab_
or somesuch so the classes don't conflict with any other classes in one's org and are easier to track for exclusion purposes in Test Suites.fflib_IdGenerator.generate(Opportunity.SobjectType)
- this way you get Ids of the proper key prefix. This becomes important when mocking polymorphic relationship fields likeOwnerId
,WhatId
, orWhoId
as the code-under-test is using thegetSobjectType()
method and these will break on strings such asOpp-1
Type
, but I wonder if it would be more natural for it to be anSobjectType
? I can't think of a time where I have ever writtenAccount.class
but often would useAccount.SobjectType
.fflib
Selector layer so code-under-test can mock the results going from, say, a fabricatedOpportunityLineItem
to itsProduct2
viaPricebookEntryId
. That is, the mocked Selector is returning fabricated Sobjects. In our shop, real world tests involve having to mockAccount + Contact + Order + OrderItem(s) + Product2(s) + PricebookEntry(s) + Pricebook2
. This is not an uncommon use case.with results: