I have below kind of wrapper class which has no methods and constructor.

public class PP_SI_Wrapper {
    public class checkBoxWrapper{
        @AuraEnabled public String que;
        @AuraEnabled public Boolean val;

    public class empWrapper {

        public Integer intId; 
        public String strName; 
        public String strEmpName ; 
        public String strGloId; 

How to achieve test coverage for this kind of class.

Thanks in advance

  • Hi @Smitha, I would suggest you include what you have tried to cover this (your actual test class), if you are unsure on how to proceed, maybe you should check Trailheads and read up on the documentation and then update your post. this will greatly improve your chances in getting an answer and additionally, will help you get those downvotes removed from your current post.
    – glls
    Jul 19 '18 at 15:48
  • I think this is a reasonable question about how code coverage works. I'm honestly not sure why there's so many downvotes. Possibly some splash damage from the many low quality questions we receive on code coverage.
    – David Reed
    Jul 19 '18 at 15:56
  • imo, lack of research, the documentation states that in Testing and Code Coverage however, my comment failed to mention anything regarding this
    – glls
    Jul 19 '18 at 16:01

You do not need, and cannot obtain, code coverage for code that is not executable:

Code coverage indicates how many executable lines of code in your classes and triggers have been exercised by test methods.

Variable declarations are not executable unless that have getter and setter methods attached, or initialization statements.

public String x;

is not coverable.

public String x { get; set; }

is, by calling the getter and/or setter methods.

public String x = myClass.getTheString();

is, by instantiating the class.

You can tell which lines can be covered by whether or not they're highlighted in the code coverage view. Your instance variables won't be unless they meet one of the definitions above. However, in your case, the code coverage view will never show anything at all, because your class contains no coverable code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.