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
Gattam Rakesh (SFDC)Gattam Rakesh (SFDC) 

How to write test class for select list and select Option

Hai  all can any one tell me how to write test class for select list and select option?
Himanshu ParasharHimanshu Parashar
can you post your select list and select option code ?
Himanshu ParasharHimanshu Parashar
This is the basic code which you can use.
MyController ctrl=new MyController();
// set up buildlist here

List<SelectOption> selOpts=ctrl.YOURSELECTOPTIONNAME;

Salesforce Certified Developer | Administrator | Service Cloud Consultant

P.S. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.
Gattam Rakesh (SFDC)Gattam Rakesh (SFDC)
yeah sure 
<apex:actionRegion >
             <b> Select Commercial Name (Variety) </b> <apex:selectList value="{!selectedProduct}" multiselect="false" size="1">
                                    <apex:selectOptions value="{!commericals}"/>                
                                <apex:actionSupport event="onchange" action="{!maincase}" reRender="pageid"/>

public List<SelectOption> commericals{get;set;}
    public DummyCreateOrderRedirectClass(ApexPages.StandardController controller) 
        commericals = new List<SelectOption>();
        Set<String> listCommercials = new Set<String>();
        OrderId= ApexPages.currentpage().getParameters().get('id');
        acc=[Select id,Name from Account where Id=:AccountId];
        ord =[Select id,Name from Order__c where id=:OrderId];
        PMLI= new Product_Master_Line_Item__c();
        PMLI1 =new List<Product_Master_Line_Item__c>();
        for(Product_Master_Line_Item__c pmi : [SELECT Id,Name,MRP__c,List_Price__c,Commercial_Name_Variety__c,Product_Master__c,Quantity__c,SKU__c,SKU_Type__c FROM Product_Master_Line_Item__c])
       system.debug('---->>>Exist Select Options'+listCommercials);
       commericals.add(new SelectOption('None','None'));
           for(String s : listCommercials)
               commericals.add(new SelectOption(s,s));
           system.debug('---->>>Final Select Options'+commericals);
 Public Void Maincase()
                    Wclass1 = new List<wrapperClass>();
                     PMLI1=[SELECT Id,Name,MRP__c,List_Price__c,Commercial_Name_Variety__c,Product_Master__c,Quantity__c,SKU__c,SKU_Type__c FROM Product_Master_Line_Item__c 
                           WHERE Commercial_Name_Variety__c=:selectedProduct ];
                        for(Product_Master_Line_Item__c p : PMLI1)
                         Wclass1.add(new wrapperClass(p));