how to cover custom setting in test class and how to get getInstance(UserInfo.getProfileId())
this is my class code
Profile_Oons__c contentesetup = Profile_Oons__c.getInstance(UserInfo.getProfileId());
how to cover custom setting in test class and how to get getInstance(UserInfo.getProfileId())
this is my class code
Profile_Oons__c contentesetup = Profile_Oons__c.getInstance(UserInfo.getProfileId());
Just like normal SObjects, your Test Context doesn't have access to the custom setting records already in the database.
You can perfectly, insert a new Custom Setting record, in your test context like you would normally do with an SObject
Whatever_custom_setting__c setting = new Whatever_custom_setting__c();
setting.Name = 'Test Setting';
setting.Value__c = 'Whatever';
insert setting;
and then your function should return the newly created test setting.
You can use below link to do query on custom setting:
Retrieving Values from Custom Settings
If you need to create custom setting in Test class, then I am much satisfy with the @Developer__c comments.
Hope it resolves your problem.