You need to sign in to do that
Don't have an account?
Bablu Kumar Pandit
How to Access Custom Setting In test Class
In Test class When we Insert Custom setting Value then It Does Not Cover But When we use seeAllData = true Then It Cover
use seeAllData =true is not Best Practice so How we Do
Please AnyOne help
use seeAllData =true is not Best Practice so How we Do
Please AnyOne help
Greetings!
You can insert a new Custom Setting record, in your test context like you would normally do with an SObject.
Please find the sample code below:
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.
Please try the above sample code and let me know,in case of any issues.
Kindly let me know if it helps you and close your query by marking it as best answer so that it can help others in the future.
Warm Regards,
Shirisha Pathuri
Something like:
If you are using it in several classes the best would be to create a TestDataFactory.
If it helps please mark as correct, it may help others.
Hii @Shirisha ,
I am Insert New Custom setting Recode In Our Test Class Like as inserting New Recode In sObject But not cover ,
is there way to cover without using seeAllData = true
I am follow your steps but not get solution
Please help me
HI Bablu, post the code to see if i can help (my code was an example do not copy exactly the same).
Please like the comment if you are making progress.
Good luck