UltimateOwnerDefaults__c UltimateOwnerDefaults = UltimateOwnerDefaults__c.getInstance();
Congratulations! You just give the gift of "Attempt to de-reference a null object" to many rule abiding test writers in the org. All those nicely done test methods (existing or future) will see no custom setting record and bomb out if they try to insert a dummy account record that largely don't really care about owner routing.
Some may advocate the pattern of using a standard environment prep procedure in all test methods. I'm never a fan of that because that has its own maintenance challenge, and it's a waste of processing time, and code character quota. My solution is the principle of "if you create it, make it friendly". It's actually pretty easy to do:
- Skip processing related to the setting if you don't have a setting record. In the above example, if UltimateOwnerDefaults == null, don't continue to the map loading and anything related to it.
- If you do still want to still process things in the absence of expected setting records (as a default behavior), provide a default value (even just hard-coded) then.
- If neither 1 or 2 a good option in real life, handle the situation (absent setting) in an exception-free way (for instance, catch and log it in some way). Really, I can't think of a good reason to have an unhandled exception coming out of a trigger for expected situations.
Done that way your new Custom Setting will never be a problem for any test methods that don't really care about it, and your code is more robust as a nice by product.