This question already has an answer here:

How to Write a test Class for Wrapper Class or Dto Class,how to call Wrapper Class in Test Class Please anyone Provide with Sample Example

marked as duplicate by Ratan Paul, Tushar Sharma, Himanshu, Sergej Utko, Adam Spriggs May 3 '16 at 11:24

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • If you have already done it for a controller, there's no much difference. Can you post your code and tell us where you struggling? – highfive May 3 '16 at 5:52

You can simply create object of inner or wrapper class by this way:

ViewRelatedController.PageSection page = new ViewRelatedController.PageSection();

pagesection here is inner class

Note: Your inner class must be public for this.

reference: How to include inner class/wrapper class in test method?


The simplest and best way i think is call the method in which you are populating the wrapper...