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
anu112anu112 

How to write test class

HI

 I am getting this Error: Compile Error: Method does not exist or incorrect signature: [checkboxex123].setacctypes() at line 29 column 9

 

public class checkboxex123{
    public list<string> acctypes=new list<string>();
    boolean disable=true;
    public list<selectoption> getitems(){
    list<SelectOption> options=new list<SelectOption>();
    //options.add(new SelectOption('Demat','Demat'));
    //options.add(new SelectOption('savings','savings'));
    return options;
    }
    
   public void setacctypes( list<string> acctypes){
  this.acctypes=acctypes;
    }
    public list<string> getacctypes(){
    return acctypes;
    }
    public PageReference test() {
        return null;
    }
    
    private static testmethod void testclass()
    {
        checkboxex123 con=new checkboxex123();
        con.getacctypes();
        con.test();
        con.getitems();
       
        con.setacctypes( );
       
    }

     
}

Best Answer chosen by Admin (Salesforce Developers) 
Big VBig V

argument to method was not correct. infact ther was no argument at all.

 

try this in test method:

 

   private static testmethod void testclass()
    {
        checkboxex123 con=new checkboxex123();
        con.getacctypes();
        con.test();
        con.getitems();
       list <string> testtypes= new   list <string>();

        testtypes.add('test1');

        testtypes.add('test2');
        con.setacctypes(testtypes );
       
    }

All Answers

Big VBig V

argument to method was not correct. infact ther was no argument at all.

 

try this in test method:

 

   private static testmethod void testclass()
    {
        checkboxex123 con=new checkboxex123();
        con.getacctypes();
        con.test();
        con.getitems();
       list <string> testtypes= new   list <string>();

        testtypes.add('test1');

        testtypes.add('test2');
        con.setacctypes(testtypes );
       
    }

This was selected as the best answer
Big VBig V
please mark it as solved if it has.
anu112anu112

Thank you Big V.