+ Start a Discussion
NatrajNatraj 

Need help to do the test coverage for the below code.... i couldn cover the below code....

 

CODE IN APEX CLASS:

public List<String> PrimaryRoles {
    get {
      if (PrimaryRoles == null) {
        PrimaryRoles = new List<String>();
        Schema.DescribeFieldResult field = Contact.Primary_Role__c.getDescribe();
         for (Schema.PicklistEntry f : field.getPicklistValues())
          PrimaryRoles.add(f.getLabel());
      }
      return PrimaryRoles;   
}
set;
}
VF CODE:

<td style="font-weight:bold;">Primary Role<br/>
<select id="primaryRole" onchange="doSearch();">
<option value=""></option>
<apex:repeat value="{!primaryRoles}" var="prole">
<option value="{!prole}">{!prole}</option>
</apex:repeat>
</select>
</td>
Best Answer chosen by Admin (Salesforce Developers) 
kiranmutturukiranmutturu

in your test class 

 

 

just pass the list of string values.....

 

list<string> lst = new list<string>{'first',second'};

 

 

like classobject.primaryroles = lst;  

 

 

try this

All Answers

kiranmutturukiranmutturu

in your test class 

 

 

just pass the list of string values.....

 

list<string> lst = new list<string>{'first',second'};

 

 

like classobject.primaryroles = lst;  

 

 

try this

This was selected as the best answer
NatrajNatraj

Thanks a lot... It worked fine