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

Unable to call the list method from controller class to test class ?
I have List method in a controller class...and i am going to call this Method in Test class. But i am getting Method does not exist or Incorrect signature error ? can any one resolve this.
This is the method in Controller class :
public List<Building_Owner__c> contactList {
get {
if (contactList == null) {
contactList = [Select id,Name,Address_1__c,Address_2__c,City__c,Contractor_Branch_Location__c,Company_Company_Location12__c,Contractor_Company_Location__c,Country__c,Email_Address__c,First_Name__c,Last_Name__c,Phone_Number__c,Postal_Code__c,State__c,Time_Zone__c from Building_Owner__c];
}
return contactList;
}
set;
}
Test Class :
LCBSBuildingOwnersController bc = new LCBSBuildingOwnersController(); // creating controller class
bc.newBuildingOwner();
bc.Order();
bc.buidingCancel();
bc.buidingSave();
bc.getContractorCompanyLoc(); // this is the page reference method calling correct
bc.contactlist(); // this is the List method (How to call this method)
This is the method in Controller class :
public List<Building_Owner__c> contactList {
get {
if (contactList == null) {
contactList = [Select id,Name,Address_1__c,Address_2__c,City__c,Contractor_Branch_Location__c,Company_Company_Location12__c,Contractor_Company_Location__c,Country__c,Email_Address__c,First_Name__c,Last_Name__c,Phone_Number__c,Postal_Code__c,State__c,Time_Zone__c from Building_Owner__c];
}
return contactList;
}
set;
}
Test Class :
LCBSBuildingOwnersController bc = new LCBSBuildingOwnersController(); // creating controller class
bc.newBuildingOwner();
bc.Order();
bc.buidingCancel();
bc.buidingSave();
bc.getContractorCompanyLoc(); // this is the page reference method calling correct
bc.contactlist(); // this is the List method (How to call this method)
This is not a method..it is a imply get set list which you have used...No need to cover it will automaatcially get covered..
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.
Thanks,
Sandeep
Salesforce Certified Developer
have you inserted Building_Owner__c record in your test class, if not then please insert and let me know...
Hi Anvesh,
Use this:
List<Building_Owner__c> ListVar = bc.getcontactList();