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
ArchestainArchestain 

Required test classes for wrapper class

Hi,

Can someone help provide the testclasses for the below wrapper class?

archestain@boom.com

Class 1:


    public with sharing Class OwnerWrapper{
    public Integer Index {get;set;}
    public List<String> tcOwner {get;set;}

        public OwnerWrapper(){
        
        }
}

Class 2:


        public with sharing class AddressWrapper {
    
        public Integer Index {get;set;}
        public List<String> Addressed {get;set;}
        
     
        publicAddressWrapper(){

        }
        
    
    }
Best Answer chosen by Archestain
ManojjenaManojjena
HI  Archestain,

You need to instantiate the wrapper class like below .

ClassName.WrapperclassName wrp=new ClassName.WrapperclassName();
Both the scenario you have given can be solved by above coding style .

One morescenario may come where you have parameter in your wrapper class constructor .In that case you need to pass the parater in side .

ClassName.WrapperclassName wrp=new ClassName.WrapperclassName(Parameters );

Check below link for some tips.

http://manojjena20.blogspot.in/2015/06/tips-and-tricks-for-test-class.html
Let me know if it helps !!
Thanks
Manoj

All Answers

ManojjenaManojjena
HI  Archestain,

You need to instantiate the wrapper class like below .

ClassName.WrapperclassName wrp=new ClassName.WrapperclassName();
Both the scenario you have given can be solved by above coding style .

One morescenario may come where you have parameter in your wrapper class constructor .In that case you need to pass the parater in side .

ClassName.WrapperclassName wrp=new ClassName.WrapperclassName(Parameters );

Check below link for some tips.

http://manojjena20.blogspot.in/2015/06/tips-and-tricks-for-test-class.html
Let me know if it helps !!
Thanks
Manoj
This was selected as the best answer
ArchestainArchestain
Thanks Manoj. It helps :)