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

Code Coverage for Wrapper Class

My Class:

public class getDealPendingApproval{
Public class wrapperClass{
       public Boolean checked{get; set;}
       public ID approvalProcessID{get; set;}
       public ID DealsRecordID{get; set;}
       public String payname{get; set;}
       public String customer_no{get; set;}
       public String customer_name{get; set;}
       public String period{get; set;}
       public String deal_id{get; set;}
       public String status{get; set;}
       public String DateStart {get; set;}
       public String VendorNumber {get; set;}
       public String DateEnd {get; set;}
       public String schemeType {get; set;}
       public wrapperClass(){} 
   public String stringCustomer {get;set;}
   Set<ID> paySet = new Set<ID>();
   Map<Id, Id> processMap = new Map<Id, Id>();
   public List<wrapperClass> wrapClassList{get; set;}
   public List<wrapperClass> wrapClassHeldList{get; set;}
   public List <Deals__c> payList {get;set;}
   public List<wrapperClass> wrapList{get; set;}
   //Number of records to be shown in each
   public Integer intPageSize {get; set;}
   //Total number of records in the search results list
   public Integer intRecordSize {get; set;}
   public ApexPages.StandardSetController con{ get; set;}
   //Total number of records in the search results list
   public integer intTotalRecords{get; set;}
   //returns the results list to be displayed on the screen
   public List<wrapperClass> testList{
        List<wrapperClass> lstWrap = new List<wrapperClass>();
      if(wrapList!=null && wrapList.size()>0){
        List<Deals__c> lstDeals = con.getRecords();
        For(Deals__c obj :  lstDeals){
            for(wrapperClass ow : wraplist){
                if(ow.DealsRecordID =={
        return lstWrap;
        return null;
   public pageReference doAction(){
        wrapList = getDeals(stringCustomer);     
        return null;

  private void setResultsInController(List<wrapperClass> wrapList){
      intPageSize = 1;
      Set<String> DealsRecordIds = new Set<string>();
      for(wrapperClass obj : wrapList){
      con  =  new ApexPages.StandardSetController([Select id from Deals__c where id in :DealsRecordIds order by createdDate desc]);
      integer intResultSize = con.getResultSize();
      if(math.mod(intResultSize,intPageSize) == 0)
        intRecordSize = (con.getResultSize())/intPageSize;
        intRecordSize = ((con.getResultSize())/intPageSize) +1;
   public List<wrapperClass> getDeals(String strCustomer){
   List<Approval.ProcessWorkitemRequest> PWRList  = new List<Approval.ProcessWorkitemRequest>();
   wrapClassList = new List <wrapperClass>();
   // get the queues which the user belongs to
   List<GroupMember> queues = [SELECT GroupId FROM GroupMember where UserOrGroupId  = :userInfo.getUserID()];
   List<String> users = new List<String>();
   //add the queues to which the user belongs
   for( GroupMember grp : queues){
  // List<ProcessInstanceWorkitem> piwiList = [SELECT ActorId,Id,IsDeleted,ProcessInstanceId, ProcessInstance.targetobjectid
    //      FROM ProcessInstanceWorkitem where actorid = :userInfo.getUserID()];
    List<ProcessInstanceWorkitem> piwiList = [SELECT ActorId,Id,IsDeleted,ProcessInstanceId, ProcessInstance.targetobjectid
          FROM ProcessInstanceWorkitem where actorid in :users];
         // create a set of the Deals ids
       for (ProcessInstanceWorkitem piwi : piwiList){
               if(String.valueof(piwi.ProcessInstance.targetobjectid.getSobjectType())== 'Deals__c'){

            payList = [select id, Customer_Name__c,, Customer_no__r.schemeType__c,  Deal_Id_Hidden__c, Deal_ID__c, DateEnd__c, VendorNumber__c, DateStart__c, Status_desc__c from Deals__c where id in
                   :paySet ];
        for(Deals__c pay : payList){
                wrapperClass wrapClass = new wrapperClass();
                wrapClass.checked = false;
                wrapClass.approvalProcessID = processMap.get(;
                wrapClass.DealsRecordID =;
                wrapClass.customer_no =;
                wrapClass.customer_name = pay.Customer_Name__c;
                //wrapClass.period = pay.period__c;
                wrapClass.deal_id =pay.Deal_Id_Hidden__c;
                wrapClass.status = pay.Status_desc__c;
                wrapclass.schemeType= pay.Customer_no__r.schemeType__c;
                wrapClass.DateEnd = + '-' + pay.DateEnd__c.month() + '-' + pay.DateEnd__c.year();
                wrapClass.VendorNumber =  pay.VendorNumber__c;
                wrapClass.DateStart = + '-' + pay.DateStart__c.month() + '-' + pay.DateStart__c.year();

   return wrapClassList;        
   } // end of getDeals

Test Class:

private class Test_getDealPendingApproval
static testMethod void testTrigger()
getDealPendingApproval pdd= new getDealPendingApproval();

Deals__c deal= new Deals__c();
insert deal;


Need Help in Code coverage. Currently coverage is 55%.
Make sure that the test will cause all of the get/set 's to be executed.
You want your test code to step through all the potential scenarios in your code.
If you have code in a get or set, but don't get or set in the test, that code does not get covered.