I have a public page (http://uat-savantsystems.cs30.force.com/Customers/five9xmlresponder) which accepts two parameters. I attempt to call the page in my test class with the parameters as such:

PageReference vfPage = new PageReference('http://uat-savantsystems.cs30.force.com/Customers/five9xmlresponder');
vfPage.getParameters().put('pin', '1111111111');
vfPage.getParameters().put('cid', '2222222');

With no luck, in debug, param1 and 2 are null, so I tried the following:

PageReference vfPage = new PageReference('http://uat-savantsystems.cs30.force.com/Customers/five9xmlresponder?param1=1111111111&param2=2222222');

and ended up with the same results.

My custom controller is called by a VF page URL. Based on the parameters, the VF page displays different XML.

It seems like the VF page just isn't getting called by the test class. What am I doing wrong?


This works for me, I hope it helps!

  PageReference tpageRef = Page.NameOfYourPageHere;

  ApexPages.currentPage().getParameters().put('Id', po.Id);

  System.assertEquals( po.id,ApexPages.currentPage().getParameters().get('Id'));
| improve this answer | |

You need to let the test framework know about your page so it can set the current page on your controller by using:


See Test Class.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.