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
Samhita ArgulaSamhita Argula 

Testing wrapper class in salesforce

This is my wrapper class
class wrapper{
        public list<Myobject> varList{
            get;
            set;
        }
        public set<id> IdVar{
            get;
            set;
        }
        public wrapper(list<Myobject> wrapList, set<id> IdSet){
            varList = wrapList;
            IdVar = IdSet;
        }
}
When I am testing it, 
wrapper wrapReq = new wrapper(varList, IdSet);
//1st condition
wrapReq = calling my method();
//2nd condition
wrapReq = calling my method();
The first wrapReq works fine. The second wrapReq is always getting NULL value. Why isn't the value being reset like it should?
Best Answer chosen by Samhita Argula
Samhita ArgulaSamhita Argula
As far as I have understood,
Wrapper cant be reset like other types for example a list or string variable.
You have to initialize it again and use it, in a different test class method.

All Answers

ANUTEJANUTEJ (Salesforce Developers) 
Hi Samhita,

>> https://salesforce.stackexchange.com/questions/87533/writing-test-class-for-wrapper-class

The above link has an implementation of writing test class for wrapper class you can try checking this and modify as needed.

Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.  

Thanks.
Samhita ArgulaSamhita Argula
As far as I have understood,
Wrapper cant be reset like other types for example a list or string variable.
You have to initialize it again and use it, in a different test class method.
This was selected as the best answer