Closed sfdcmatt closed 7 years ago
Good point @sfdcmatt
I'm thinking of adding an initial check at start of the test method to see if communities are even enabled. If not then exit gracefully otherwise continue on. The check would be like I did in the attachment conversion project:
Boolean communitiesEnabled = ContentVersion.sObjectType.getDescribe().fields.getMap().containsKey( 'NetworkId' );
If communities are enabeld then the org should have the standard profile for the test method to use. If not then the test still has to fail if the profile can't be found.
Besides all that, yes, I agree with your recommendation that it's best practice to query for list, check size, react accordingly.
Thanks!
Thanks!
The ConvertNotesToContentNotesServiceTest.test_partner_community_users() method fails at line 25 when Communities isn't enabled in an org, because it can't find a Profile with the specified name. Error message is:
List has no rows for assignment to SObject stack Class.ConvertNotesToContentNotesServiceTest.test_partner_community_users: line 25, column 1
Instead of binding to a single sObject instance, it should bind to a collection and inspect if the collection is null, then branch / handle accordingly.