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

  • 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, 2016 at 5:52

2 Answers 2


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...