+ Start a Discussion
RoyalRoyal 

how to create custom setting data into test class ?

how to create data in test class for custom setting, with out using SeeAllData=true.
custom setting name is: AllCodeValues__c,  and field name is : firstcode__c
when you click the manage button on customm settings values are like below...
Atmakur    0012
Kavali       0013
kaluvai     0014
like this values is there so how can create data for this in test class.


thanks in advance.
povery.sf@gmail.compovery.sf@gmail.com
List<AllCodeValues__c> acv = new List<AllCodeValues__c>();
acv.add(new AllCodeValues__c(Name = 'abc'));
insert acv;
Pramodh KumarPramodh Kumar
Custum setting is same like object.

Here is the sample code for inserting the custum setting data

 Category__c,Sub_Category__c, Priority__c, SLA__C, Name  are my custum setting fields
 
        YourCustumSettingName__C csobj=new YourCustumSettingName__C ();
        csobj.Category__c='Other';
        csobj.Sub_Category__c='Other';
        csobj.Priority__c='1';
        csobj.SLA__c=120;
        csobj.name='Dataset1';
        insert csobj;
Let me know if you have any other question


Thanks,
pRAMODH.