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
keerthana chowdharykeerthana chowdhary 

testclassss for wrapper class


public with sharing class sccQuestionList {
    
    Public Integer noOfRecords{get; set;}

    Public Integer size{get;set;}

    Public List<wrapperclass> wrapList{get;set;}

    Public boolean showFlagcheck{get;set;}

    public ApexPages.StandardSetController setCon {
        
 
        get{

            if(setCon == null){

                size = 10;
                
                Id UserId = UserInfo.getUserId();

                string queryString = 'Select Id,Name, 

Line_Of_Discipline_C__r.Name,Status_C__c,Priority_C__c,Owner.name,Line_Of_Discipline_Focal_Point__r.Name,Site__c,Title_C__c,CreatedDate,CreatedById  from Question__c 

where CreatedById =: UserId order by CreatedDate DESC';

                setCon = new ApexPages.StandardSetController(Database.getQueryLocator(queryString));

                setCon.setPageSize(size);

                noOfRecords = setCon.getResultSize();

               wrapList = new List<wrapperclass>();

         
 
            }

            return setCon;

        }set;

    }

     
 
    /*Public Pagination_Demo(){

      wrapList = new List<wrapperclass>();

    } */

      
 
    Public List<Question__c> getQuestions(){

        List<Question__c> queList = new List<Question__c>();

        for(Question__c q : (List<Question__c>)setCon.getRecords())

            queList.add(q);

        return queList;

    }

     
 
    Public List<wrapperclass> getwrapListshow(){

        List<Question__c> queList = new List<Question__c>();

        wrapList = new List<wrapperclass>();

        for(Question__c q : (List<Question__c>)setCon.getRecords())
        {

            wrapList.add(new wrapperclass(q,false)) ;

            queList.add(q);

        }

        showFlagcheck = true;

        return wrapList ;

    }

     
 
    Public class wrapperclass{

         Public Question__c ques{get;set;}

         Public Boolean flagcheck{get;set;}

         Public wrapperclass(Question__c que,boolean checkBox){

           ques = que;

           flagcheck = checkbox;

 
 
         }   
 
    }

       
 
    public pageReference refresh() {

        setCon = null;

        getQuestions();

        setCon.setPageNumber(1);

        return null;

    }

    //This is called by action poller in visualforce page

    Integer count = 0;

    public PageReference incrementCounter() {

        count = setCon.getPageNumber();

        return null;

    }


}
can u please help me

my test class
@isTest
public class testsccQuestionlist {
static testmethod void ssc()
{
    Question__c  Q=new Question__c ();
    insert Q;
    
    PageReference pageRef = Page.conatactsaved;
    pageRef.getParameters().put('id', String.valueOf(Q.Id));
    Test.setCurrentPage(pageRef);
   sccQuestionList.wrapperclass sccQuestion = new sccQuestionList.wrapperclass(Q);
   //sccQuestion.getQuestions();
  }
}
pconpcon
What are you having problems doing?  Just providing a large class and a small test class that does not provide any real testing.

NOTE: When including code please use the "Add a code sample" button (icon <>) to increase readability and make referencing code easier.
Amit Chaudhary 8Amit Chaudhary 8
Please try below code. I hope that will help you
@isTest
public class testsccQuestionlist {
static testmethod void ssc()
{
    Question__c  Q=new Question__c ();
    insert Q;
    
    PageReference pageRef = Page.conatactsaved;
    pageRef.getParameters().put('id', String.valueOf(Q.Id));
    Test.setCurrentPage(pageRef);
	
	sccQuestionList cont = new sccQuestionList();
	List<Question__c> lst = cont.getQuestions();
	
	//cont.wrapList = cont.getwrapListshow();
	
  }
}