0
  public with sharing class ResponseWrapper{
    public String Id;
    public String Time; 
    public String lobType;
    public String businessContextId;
    public Information[] document;

    public class Information{
    public String id;  
    public String type;
    public String context;
    public ErrorInformation[] errors;
    public Data data;
  }

  public class ErrorInformation{
    public String code;  
    public String description;  
  }

  public class Data Data {
    public PersonDetail[] person;
  }

  public class PersonDetail{
    public String firstName;
    public String lastName;
    public Integer age;
    public String gender;  
  }

above is my wrapper class i want to write a test class for the same, as my wrapper class don't have any method/constructor the covering lines are coming 0% so for writting test class for this i have created a method that is returing instance of this class is this approach is fine, or i should try something else?

 public with sharing class ResponseWrapper{
    public String Id;
    public String Time; 
    public String lobType;
    public String businessContextId;
    public Information[] document;

    public class Information{
    public String id;  
    public String type;
    public String context;
    public ErrorInformation[] errors;
    public Data data;
  }

 public class ErrorInformation{
    public String code;  
    public String description;  
 }

 public class Data Data {
    public PersonDetail[] person;
 }

 public class PersonDetail{
    public String firstName;
    public String lastName;
    public Integer age;
    public String gender;  
 }

 public static ResponseWrapper getInstance(){
    return new ResponseWrapper();     
 }
3

Your class is not covered because it contains no executable lines of code. There is nothing to cover.

It is not necessary to add a constructor for the purpose of simulating coverage. Code coverage is defined as a percentage is executable lives covered, so your wrapper class requires no test class and does not impact your org's coverage.

| improve this answer | |

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.