+ Start a Discussion
I'm from MarsI'm from Mars 

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!!
I'm from MarsI'm from Mars
Thank u so much Rajesh & Devdas that's worked for me
DevADSDevADS
Please close this thread by marking the best answer.