You need to sign in to do that
Don't have an account?

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?
You need to sign in to do that
Don't have an account?
Thanks,
Himanshu
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.
Page:
<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"/>
</apex:selectList>
</apex:actionRegion>
Class:
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');
AccountId=ApexPages.currentpage().getParameters().get('AccountId');
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])
{
if(pmi.Commercial_Name_Variety__c!=Null)
{
listCommercials.add(pmi.Commercial_Name_Variety__c);
}
}
system.debug('---->>>Exist Select Options'+listCommercials);
if(!listCommercials.isEmpty())
{
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()
{
Show=true;
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));
}
}