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
Linga_RaminLinga_Ramin 

I'm unable to cover below Query in Test class.Can anyone help me out?

          String pvd = apexpages.currentpage().getparameters().get('pv');

         Pl_target_c target =[Select Name from Pl_target_c where Id=:Id.valueOf(pvd) LIMIT 1];
 
Rajesh3699Rajesh3699
Hi,

Create a test record for Pl_target_c object and pass the record Id as the parameter of the URL i,e pv

 PageReference pageRef = Page.YourPageName;
 Test.setCurrentPage(pageRef);
 pageRef.getParameters().put('pv', String.valueOf(Pl_target_c  Id));

Thank You,
Rajesh Adiga P.
DevADSDevADS
Hey PM Chowdary,

You need to set target page like below -
PageReference pageRef = Page.<TargetPage>;
Test.setCurrentPage(pageRef);
ApexPages.currentPage().getParameters().put('pv',<Id>);

Do post here if you have any further questions.

Happy Coding!!
Linga_RaminLinga_Ramin
Thank u so much Rajesh & Devdas that's worked for me
DevADSDevADS
Please close this thread by marking the best answer.