Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a public page ( which accepts two parameters. I attempt to call the page in my test class with the parameters as such:

PageReference vfPage = new PageReference('');
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('');

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?

share|improve this question

This works for me, I hope it helps!

  PageReference tpageRef = Page.NameOfYourPageHere;

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

share|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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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