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 apexpages.currentpage.getparemeter() 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];

Best Answer chosen by Admin (Salesforce Developers) 
Puja_mfsiPuja_mfsi

Hi,

You need to use 'apexpages.currentpage().getparameters().put("recordid","value")' in test class to cover the same lines:

As:

apexpages.currentpage().getparameters().put("recordid","value")

Put your value in place of value highlated in red

 

 

Please let me know if u have any query on same and if this post helps u plz give KUDOS by click on star at left.

All Answers

Sgt_KillerSgt_Killer

Try this out -

 

PageReference pageRef = new PageReference('/apex/VFPage');
pageRef.getParameters().put('recordid' , Reccord.id);
pageRef.getParameters().put('request' , request value);
Test.setCurrentPageReference(pageRef);

Puja_mfsiPuja_mfsi

Hi,

You need to use 'apexpages.currentpage().getparameters().put("recordid","value")' in test class to cover the same lines:

As:

apexpages.currentpage().getparameters().put("recordid","value")

Put your value in place of value highlated in red

 

 

Please let me know if u have any query on same and if this post helps u plz give KUDOS by click on star at left.

This was selected as the best answer
sandeep@Salesforcesandeep@Salesforce

first of all you need to set these parameters and then you can test it again as below

 

apexpages.currentpage().getparameters().put('id' ,'XXXXXXXXXXXXx' );

 

now in test method you can get it

 

ApexPages.currentPage().getParameters().get('id');

ezhil_kezhil_k

Thank You all for your answers!