function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Varun AnnadataVarun Annadata 

help with the test class

hi all
       this is the custom setting object in my class
   1) FrCCC_SearchDisplaySettings__c srchDispCS = FrCCC_SearchDisplaySettings__c.getValues('Account');
and if condition in the class is
 if(srchDispCS != null && srchDispCS.FrCCC_FieldNames__c != null){query = 'SELECT '+srchDispCS.FrCCC_FieldNames__c;}

how to give values to srchDispCS,srchDispCS.FrCCC_FieldNames__c in test class so if condition becomes true
2)public boolean isSalesRepMSEAccess =false;     
  public boolean isSalesRepMMFAccess =false;
 public boolean getIsSalesRepMMFAccess(){         return Schema.sObjectType.Account.fields.FrCCC_MMF_TerritoryName_KAM__c.isAccessible();     }
if(salesRep != null && !salesRep.trim().equalsignorecase(blankStr) && isSalesRepMSEAccess){                 query += salesRepMSEVar+' like \'%'+salesRep +'%\' and ';                 flag= true;}
this is the method and if conition in my original class
how to supply values for isSalesRepMSEAccess in my test class so if condition evaluates to true
 
Rohit B ☁Rohit B ☁
Hi Varun,
For the first point, just make an insertion like we do for a normal custom object in your test class for setup test data.

For the second point, call your getter setter by the class instance like this:-
ClassName clsObject = new ClassName();
clsObject.isSalesRepMMFAccess();

It will set the value to ""isSalesRepMMFAccess" variable.
Varun AnnadataVarun Annadata
for the second one when i try to create clsObject.isSalesRepMMFAccess();it is showing method does not exist error.