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

Test.setCurrentPageReference error

Hi everyone,

 

I started to get the following error message today, everything was working fine and now I can't deploy my classes because the test units fail due to some incorrect signature in the setCurrentPageReference method inside the Test class.

 

I'm getting the following error message:

 

Save error: Method does not exist or incorrect signature: Test.setCurrentPageReference(System.PageReference)

 

Any ideas on what's happening? Can this be related to the Spring '10 upgrade? It's frustrating that this kind of things happen when you're ready to deploy your stuff to production.. 

 

 

 

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
aballardaballard

Forget that, I had a problem in my code.  It seems to work ok for me.

 

In my case, I had a class of my own called Test which was conflicting with the system defined Test class. 

All Answers

aballardaballard

It does seem like that is broken.   As a workaround, if you explicitly cast to System.Pagereference it seems to work ok.

 

aballardaballard

Forget that, I had a problem in my code.  It seems to work ok for me.

 

In my case, I had a class of my own called Test which was conflicting with the system defined Test class. 

This was selected as the best answer
jonathanrico.jonathanrico.

Thanks for your reply, 

 

I'm only getting this behavior in sandbox.. I have similar test methods in a developer org and i'm not getting this error. 

jonathanrico.jonathanrico.
any one else having the same issue??
Himanshu ParasharHimanshu Parashar

You have to explicitly prefix system before Test.setCurrentPageReference so it will be like this

 

system.Test.setCurrentPageReference(pageRef);

kantravikantkantravikant

list<Account>lstAcc=..........

ApexPages.StandardSetController controller = new ApexPages.StandardSetController(lstAcc);
FunderController f = new FunderController(controller);

-------------

set the page in test case

PageReference pgRef = Page.page_name;
system.Test.setCurrentPageReference(pgRef);