You need to sign in to do that
Don't have an account?
Puja Patil 18
How to write @Test Class
How to write @Test Class for Following Controller :
public with sharing class ReportController {
Public Id lookupid{get;set;}
public Question_Bank_Page__c obj1{get;set;}
public Question_Option__c lookup;
public List<Question_Option__c> OptionList{get;set;}
public List<Question_Option__c> OptionList2{get;set;}
public Question_Option__c Option{get;set;}
private ApexPages.StandardController controller;
public PageReference lookupid() {
System.debug('****************Lookup id new*1************************'+obj1.Feedback__c);
return null;
}
public ReportController(ApexPages.StandardController controller) {
obj1= (Question_Bank_Page__c)controller.getRecord();
System.debug('****************Lookup id new*2************************'+obj1.Feedback__c);
}
public PageReference PassingParameter(){
lookupid=obj1.Feedback__c;
system.debug('++++++++++++++++LOOKUP ID++++++++++++++++++++'+lookupid);
OptionList=[Select Customer_Name__c, CreatedDate, Customer_Email__c, Customer_Phone__c, Response__c, Question__r.Related_Feedback__r.Feedback_Name__c,
Question__r.Related_Feedback__r.Count_Question__c, Question__r.Related_Feedback__r.Feedback_Taken_by_Contact__c, Question__r.Question__c,
Question__r.Related_Feedback__r.CreatedDate From Question_Option__c where Question__r.Related_Feedback__c=:lookupid Limit 1];
system.debug('++++++++++++++++++++OPTION LIST++++++++++++++++++++'+OptionList);
OptionList2=[Select Customer_Name__c, CreatedDate, Response__c, Question__r.Question__c From Question_Option__c where Question__r.Related_Feedback__c=:lookupid];
system.debug('++++++++++++++++++++OPTION LIST++++++++++++++++++++'+OptionList2);
return null;
}
public with sharing class ReportController {
Public Id lookupid{get;set;}
public Question_Bank_Page__c obj1{get;set;}
public Question_Option__c lookup;
public List<Question_Option__c> OptionList{get;set;}
public List<Question_Option__c> OptionList2{get;set;}
public Question_Option__c Option{get;set;}
private ApexPages.StandardController controller;
public PageReference lookupid() {
System.debug('****************Lookup id new*1************************'+obj1.Feedback__c);
return null;
}
public ReportController(ApexPages.StandardController controller) {
obj1= (Question_Bank_Page__c)controller.getRecord();
System.debug('****************Lookup id new*2************************'+obj1.Feedback__c);
}
public PageReference PassingParameter(){
lookupid=obj1.Feedback__c;
system.debug('++++++++++++++++LOOKUP ID++++++++++++++++++++'+lookupid);
OptionList=[Select Customer_Name__c, CreatedDate, Customer_Email__c, Customer_Phone__c, Response__c, Question__r.Related_Feedback__r.Feedback_Name__c,
Question__r.Related_Feedback__r.Count_Question__c, Question__r.Related_Feedback__r.Feedback_Taken_by_Contact__c, Question__r.Question__c,
Question__r.Related_Feedback__r.CreatedDate From Question_Option__c where Question__r.Related_Feedback__c=:lookupid Limit 1];
system.debug('++++++++++++++++++++OPTION LIST++++++++++++++++++++'+OptionList);
OptionList2=[Select Customer_Name__c, CreatedDate, Response__c, Question__r.Question__c From Question_Option__c where Question__r.Related_Feedback__c=:lookupid];
system.debug('++++++++++++++++++++OPTION LIST++++++++++++++++++++'+OptionList2);
return null;
}
is Feedback__c required field or Masterdeatils relation ship to Question_Bank_Page__c object?.
If there r no required fields and no masterdetail relation ships then below code works. If there are required field/masterdetail relationships then add the same to 'qbp' object below.
Thanks,
Nagendra
All Answers
is Feedback__c required field or Masterdeatils relation ship to Question_Bank_Page__c object?.
If there r no required fields and no masterdetail relation ships then below code works. If there are required field/masterdetail relationships then add the same to 'qbp' object below.
Thanks,
Nagendra
Hi Puja Patil,
Please find this link for Ref : https://developer.salesforce.com/forums/?id=906F0000000BVY5IAO (https://developer.salesforce.com/forums/?id=906F0000000BVY5IAO" target="_blank)
Please let me know after trying this.https://developer.salesforce.com/page/An_Introduction_to_Apex_Code_Test_Methods
I have provided some idea to do before this create mandatory fields.
Thanks,
Jagadeesh
I will try it.