You need to sign in to do that
Don't have an account?
yarram
how to write test class for this Controller class
Hi All,
i am not able to cover getter method "if " statement code in my test class
how to write test class for this Controller class List variable getter method "if" satatement
public with sharing class listtestCtrl {
public List<Opportunity> listOpp{
get{
String query='Select id,LeadSource,Name,StageName,Type from Opportunity ';
if((this.selectedLeadSource!='All Sources') && (this.selectedLeadSource!= null)){
query=query+'Where LeadSource=:selectedLeadSource';
}
if((this.selectedType!='All Types') && (this.selectedType!= null)){
query=query+'AND Type=:selectedType';
}
query += ' ORDER BY LeadSource';
return (List<Opportunity>)database.query(query);
}
set;
}
}
Please help me .
Thanks in advance.
Thanks,
Yarram
i am not able to cover getter method "if " statement code in my test class
how to write test class for this Controller class List variable getter method "if" satatement
public with sharing class listtestCtrl {
public String selectedType{get;set;}
public String selectedLeadSource{get;set;}
public String selectedLeadSource{get;set;}
get{
String query='Select id,LeadSource,Name,StageName,Type from Opportunity ';
if((this.selectedLeadSource!='All Sources') && (this.selectedLeadSource!= null)){
query=query+'Where LeadSource=:selectedLeadSource';
}
if((this.selectedType!='All Types') && (this.selectedType!= null)){
query=query+'AND Type=:selectedType';
}
query += ' ORDER BY LeadSource';
return (List<Opportunity>)database.query(query);
}
set;
}
}
Please help me .
Thanks in advance.
Thanks,
Yarram
All Answers