NPSP icon indicating copy to clipboard operation
NPSP copied to clipboard

Cannot Adjust Custom Settings in a Unit Test. As a consequence, there is no way to test scenarios that require adding an address to an organization.

Open MenachemShanowitz opened this issue 10 months ago • 0 comments

Hi,

Due to line 107 in UTIL_CustomSettingsFacade, there is no way to adjust the NPSP "Contact and Org Settings" because it loads default settings when running in test mode, see code below.

This is important particularly because it would enable adding addresses to organizations, a very common use case.

public static npe01__Contacts_And_Orgs_Settings__c getContactsSettings() {
        if(Test.isRunningTest() && contactsSettings == null) {
            contactsSettings = new npe01__Contacts_And_Orgs_Settings__c();
            configContactsSettings(contactsSettings);
        } else if (contactsSettings == null) {
            contactsSettings = npe01__Contacts_And_Orgs_Settings__c.getInstance();
            if(contactsSettings.Id == null)
                contactsSettings = getOrgContactsSettings();
        }
        return contactsSettings;
    }

MenachemShanowitz avatar Aug 18 '23 12:08 MenachemShanowitz