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
Etienne Gaudry 5Etienne Gaudry 5 

Wrapper Test

Hi, i try to test my wrapper class but i have actually 0% coverage.

My wrapper is like :

public class EU01AccountApiWrapper {

    public String code;
    public String name;
    public cls_status status;
    public String website;

...
In my test method i have try to create a wrapper 
EU01AccountApiWrapper wrapper= new EU01AccountApiWrapper();
    wrapper.code = 'Test Wrapper';
    wrapper.name = 'Test Wrapper';


But i have 0%. How can i do ? Ty :)

Best Answer chosen by Etienne Gaudry 5
Devi ChandrikaDevi Chandrika (Salesforce Developers) 
Hi Etienne,
No need to cover this wrapper class.There are no executable lines of code in your class.Variable declarions are not counted as part of code coverage.
If you have constructor in your wrapper class then you have to cover that because it is executable.

Please refer below link which might help you in this
https://salesforce.stackexchange.com/questions/288405/wrapper-class-is-not-covered-in-the-test-class
If you have contructor in your wrapper class try this way
https://developer.salesforce.com/forums/?id=9060G000000MVoaQAG

Hope this helps you
Let me know if this helps you. Kindly mark it as solved so that it may help others in future.

Thanks and Regards

All Answers

Pawel BorysPawel Borys
I don't think you can cover variable declarations. Try adding an empty constructor
Devi ChandrikaDevi Chandrika (Salesforce Developers) 
Hi Etienne,
No need to cover this wrapper class.There are no executable lines of code in your class.Variable declarions are not counted as part of code coverage.
If you have constructor in your wrapper class then you have to cover that because it is executable.

Please refer below link which might help you in this
https://salesforce.stackexchange.com/questions/288405/wrapper-class-is-not-covered-in-the-test-class
If you have contructor in your wrapper class try this way
https://developer.salesforce.com/forums/?id=9060G000000MVoaQAG

Hope this helps you
Let me know if this helps you. Kindly mark it as solved so that it may help others in future.

Thanks and Regards
This was selected as the best answer
Etienne Gaudry 5Etienne Gaudry 5
Thank you for this answer :)