I am using a util class with a singleton pattern to retrieve the custom settings. Like below:
private static Additional_System_Settings__c addSysSetting;
public static Additional_System_Settings__c getAdditionalSystemSetting() {
if(addSysSetting == null) {
addSysSetting = Additional_System_Settings__c.getInstance(UserInfo.getUserId());
}
return addSysSetting;
}
The only thing I am worried about is I am using the current user's user info to retrieve the related custom setting which means if in the test environment if I have System.runas() in my code and has that custom setting variable initialised before the system.runas() part, the runas() section will be probably be using the previous user's setting.
I am not quite sure that in this scenario, since these are run under two user's identities, will that be running in two different execution context or not? And should I be worried about this at all?