You don't need test classes for custom settings, however if you need to use custom settings in your code that you are testing, you can just insert them like any other sObject.
I think, it is mandetory to create custom settings in test classes wherever you use them as while doing deployments; you new envirnment is not always setup with custom settings all the time or values might change in those custom setting which can make things inconsistent.
How to create:
@isTest(SeeAllData=FALSE)
private class MyTestClass {
//Initialize custom settings to prevent test failures
private static Setting__c settingsInstance;
static {
settingsInstance = new Setting__c();
settingsInstance.Field1__c = TRUE;
settingsInstance.Field2__c = FALSE;
upsert settingsInstance;
}
static testMethod void TestSAPAddressCheck() {
Test.startTest();
//Your unit test here
Test.startTest();
}
}
Hope this helps! Mark it as solution if this solves your problem.
How to create:
Hope this helps! Mark it as solution if this solves your problem.