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
rcravenrcraven 

Apex unit test exception Test.setCurrentPage() method not avaliable?

In our Sandbox environment, "cs13", we have noticed that our unit tests for apex controller classes have started failing due to the below error message:

- Method does not exist or incorrect signature: Test.set CurrentPage(System.PageReference)

We're using API version 24.0. This is an internal Salesforce object "Test" and a standard Salesforce method, "setCurrentPage()". This method is used by a unit test to set the current page reference to test against, without it, code coverage is 0% for any apex controller class.

This is impacting our current ability to deploy code to production, which we would like to do this weekend.

 

Can anybody shed some light on this problem.  Am I using the wrong API version?

Best Answer chosen by Admin (Salesforce Developers) 
rcravenrcraven

We had an Apex class named, "Test" in our sandbox org which by name only was overriding the system class "Test".  Removing the class "Test" from our sandbox org resolved the error.  However, it leaves we wondering why aren't system classes "sealed" or in another namespace?   I don't understand the use case for overriding the system class, and it just seems like bad programming to me.

All Answers

rcravenrcraven

I've reverted back to API version 20.0, still same issue.

 

In addition Usage of Test.isRunningTest() is also failing.

rcravenrcraven

We had an Apex class named, "Test" in our sandbox org which by name only was overriding the system class "Test".  Removing the class "Test" from our sandbox org resolved the error.  However, it leaves we wondering why aren't system classes "sealed" or in another namespace?   I don't understand the use case for overriding the system class, and it just seems like bad programming to me.

This was selected as the best answer