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
dkndkn 

test method for controller extensions

Hi..

 

I am trying to write an test method for the below controller extension (contact controller extension).

I am finding difficult to start writing this test method....Please help me....i would really appreciate any help..

I have written this to create a mass update , i can select a number of contacts from the view and update the status....

 

This controller returns the number of selected records...

 

 

public class massupdate {

    ApexPages.StandardSetController setApp;

    public massupdate(ApexPages.StandardSetController controller) {
        setApp = controller;
    }
    
   
    public integer getMySelectedSize() {
        return setApp.getSelected().size();
    }
   
}

 

thank you

hisrinuhisrinu

You can use something like below

 

 

List<account> accountList = new List<account>();

Accunt a1 = new account(provide values here);

Accunt a2 = new account(provide values here);

accountList.add(a1);

accountList.add(a2);

insert accountList;


ApexPages.StandardSetController ssc = new ApexPages.StandardSetController(accountList);

 

then write the normal way of writing a test method