function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
anvesh@force.comanvesh@force.com 

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)

 
sandeep sankhlasandeep sankhla
Hi Anvesh,

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 
anvesh@force.comanvesh@force.com
BUt it was not  covered. i have verified in devoloper console.
sandeep sankhlasandeep sankhla
Hi Anvesh,

have you inserted Building_Owner__c record in your test class, if not then please insert and let me know...

 
anvesh@force.comanvesh@force.com
yes i have inserted.
Sanjay.GeorgeSanjay.George

Hi Anvesh,

Use this:

 List<Building_Owner__c>  ListVar = bc.getcontactList();