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
ezhil_kezhil_k 

how to cover this line in test class

idstring= apexpages.currentpage().getparameters().get('recordid');
 requestStatus =apexpages.currentpage().getparameters().get('request');
 } 
 Public pagereference ChangeAccount(){
 try{
List<string> recordIdList= idstring.split(',');
info=[select id,accountid__c,contactid__c,status__c,rejected__c from CompanyRequestInfo__c  where id in: recordIdList];

Deepak Kumar ShyoranDeepak Kumar Shyoran

Hi ezhil_k,

 

To these line from test class you the thing you need to do is to create some records of CompanyRequestInfo__c  object within your test class in then use those records id to put in current page parameter recordid in comma separated way. Use following code to in your test class to cover above lines.

 

@isTest

 

List<CompanyRequestInfo__c >  compReqList = new List<CompanyRequestInfo__c  >() ;

compReqList.add(new CompanyRequestInfo__c (name ='Test1')) ; // Also fill required field information otherwise this record fail to insert in database.

compReqList.add(new CompanyRequestInfo__c (name ='Test2')) ; // Also fill required field information otherwise this record fail to insert in database.

 

insert compReqList ;

 

Apexpages.currentpage().getparameters().put('recordid',compReqList[0].Id+','+compReqList[1].Id) ;

 

Modify above code according to your need. 

Now try to execute that method which have these line.

 

If this post helps you then hit kudus by clicking on star and accept my post as a solution to your question.