You need to sign in to do that
Don't have an account?
How to write a test case for the controller
Hi,I am new to thissalesforce.I finishe my controller class now iam trying to write testclass for that
how do i write testcase for my controoler;
here is my controller:
public class status_ctrl_option{
public status_ctrl_option()
{
//statusop = false;
showselectlist = false;
updateshowResults();
count = 0;
showstatusdialog = false;
}
public integer count {get;set;}
public boolean statusop {get;set;}
public boolean showselectlist {get;set;}
public boolean showResults {get;set;}
public string pgName {get;set;}
public string productId {get;set;}
public string newstatus_Name {get;set;}
public string new_currentbuildstaus_Name{get;set;}
public string new_nexttbuildstaus_Name {get;set;}
public boolean showstatusdialog {get;set;}
public string status_Id{get;set;}
public string status_Name {get;set;}
public string status_CurrentBuild {get;set;}
public string status_NextBuild {get;set;}
public list<Product_Group__c> returnproductlist = new list<Product_Group__c>();
public list<Product_Group__c> getreturnproductlist()
{
return returnproductlist;
}
public void pgsearchlist()
{
returnproductlist = [SELECT Id, Name, Quick_Pricing__c, Quick_Pricing_Name__c, Pricing_Type__c,Contract_Template__c,Engineering_Engagement__c,Engineering_Cycle_Time__c
FROM Product_Group__c
WHERE Name = : pgName];
updateshowResults();
}
public void updateshowResults()
{
showResults = false;
if(returnproductlist.size() > 0)
{
showResults = true;
}
}
Product_Group__c selectepglist = new Product_Group__c();
public Product_Group__c getselectepglist()
{
return selectepglist;
}
public void selectedpgnamelist()
{
selectepglist = [SELECT Id, Name, Quick_Pricing__c, Quick_Pricing_Name__c, Pricing_Type__c,Contract_Template__c,Engineering_Engagement__c,Engineering_Cycle_Time__c
FROM Product_Group__c
WHERE Id = : productId limit 1];
if(selectepglist.Engineering_Engagement__c == 'Required' && selectepglist.Engineering_Cycle_Time__c != null)
{
updatestatusop();
updateBuildStatuses();
updateBuildStatusOptions();
}
editshowselectlist();
}
public void editshowselectlist()
{
showselectlist = false;
if(selectepglist != null)
{
showselectlist = true;
}
}
public PageReference pg_update()
{
Product_Group__c updatelist = new Product_Group__c();
updatelist = selectepglist;
updatelist.Quick_Pricing__c = selectepglist.Quick_Pricing__c;
updatelist.Pricing_Type__c = selectepglist.Pricing_Type__c;
updatelist.Engineering_Engagement__c = selectepglist.Engineering_Engagement__c;
updatelist.Contract_Template__c = selectepglist.Contract_Template__c;
update updatelist;
/*if(updatelist.Engineering_Engagement__c == 'Required')
{
updatestatusop();
updateBuildStatuses();
updateBuildStatusOptions();
}*/
PageReference pr = new PageReference('/apex/status_option');
pr.setRedirect(true);
return pr;
}