-
Notifications
You must be signed in to change notification settings - Fork 14
Documentation / installation / readme points #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
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. #3 - I like xxx.SObjectType solely for the familiarity and consistency with other code, notably fflib. #4 - if you are unit testing a method that updates sobject xxxx, you can't fabricate that object as the code-under-test DML will fail. Similarly, if you fabricate an Account sobject and the code under test tries to insert an Opportunity or Case or Contact, the code will fail because the lookupId won't exist in the database. 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. #5 Yes. 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 ***@***.***> wrote:
@cropredyHelix <https://github.com/cropredyhelix> I merged #3
<#3> which addresses
the prefix suggestion.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2 (comment)>,
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:
The text was updated successfully, but these errors were encountered: