Create records for Custom Setting to avoid null values from Custom Settings in Test class in Salesforce.
Syntax:
@isTest
public class testClass {
@TestSetup static void setupData() {
SampleCustomSettings__c obj = new SampleCustomSettings__c(Name = ‘Testing’);
insert obj;
}
static testMethod void test() {
Test.StartTest();
/*…………..
…………..*/
Test.stopTest();
}
}
Cheers!!!