You need to sign in to do that
Don't have an account?
Linga_Ramin
Unable to cover below Custom Setting in test class.How to fetch custom setting data to test class?
Type__c theRec = Type__c.getInstance(op); // Custom Setting
if(theRec != null && theRec .Duration__c == true){
map<String,Product__c> mapData = new Map<String,Product__c>();
for(Product__c lstRev:Database.query(strFinalQuery)){
mapData.put( lstRev.Period__c, lstRev);
}
if(theRec != null && theRec .Duration__c == true){
map<String,Product__c> mapData = new Map<String,Product__c>();
for(Product__c lstRev:Database.query(strFinalQuery)){
mapData.put( lstRev.Period__c, lstRev);
}
Insert the Record for custom Setting in test class methods before the custom setting refered then it will cover you code:
@isTest
public class testClass {
static testMethod void test() {
// Add the remaining Fields and values for custom setting in below
//The below will insert the record in Custom setting then you can refer the values
Type__c obj = new Type__c (Name = 'Testing');
insert obj;
/*....Do your further Action after insert the Cusom setting.....
..............*/
}
}
You can also use the Test Setup: http://www.infallibletechie.com/2013/12/getting-null-values-from-custom.html
Thanks,
Maharajan.C