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
Arun_PaliArun_Pali 

Compilation error..

Hello friends,
I get an error while trying to compile the test coverage classes.

Error: Compile Error: Method does not exist or incorrect signature: Test.setCurrentPage(System.PageReference) at line 39 column 9

This error starts occuring only after I created a managed package for my app. Any idea friends ?

Below is my code :

PageReference pageRef = Page.testpage1;
Test.setCurrentPage(pageRef);


Any hints would be helpful !!

Thanks.
Sam.arjSam.arj
Hi Arun
Make sure your test method starts this way:
Also Call setCurrentPageReference instead of SetCurrentPage.

Code:
static testMethod testingmytestpage1()
{
   PageReference pageRef = Page.testpage1;
   Test.setCurrentPageReference(pageRef);
}

 

Sam.arjSam.arj

I have posted on article on this blog on how to get a good test coverage on your visualforce pages.

http://salesforcesource.blogspot.com/2008/09/geting-good-test-coverage-on-vf-pages.html

http://salesforcesource.blogspot.com/2008/09/geting-good-test-coverage-on-vf-pages.html

Salesforce developer wiki also have very good examples.
Good luck,


Arun_PaliArun_Pali
Thanks very much Sam. This link was very useful. And I forgot to let you know,
Test.setCurrentPageReference worked for me :-); Thanks a lot Sam !!
Arun_PaliArun_Pali
Hi Sam,
By anychance do you know whether is it good to have 2 test classes for a single controller class. The reason being, my controller class is 700 lines long and contains lots of conditions. When I tried to write test methods for all the conditions, the test class became very huge and hence throwed an error saying that the class is huge. So now I plan to split the test methods between 2 different classes. Is this a good practise ? Is there any other alternative you would suggest ?



Thanks.
Sam.arjSam.arj
I believe that is possible.

You may also want to divide your heavy visualforce page into smaller components (some that might be reusable later on) and then have separate classes to test the components out.

Having the code divided into smaller pieces (Components) makes all more manageable later on when you want to support/troubleshoot or improve (add/remove feature) your page.
Cheers,
  Sam

Arun_PaliArun_Pali
Thanks for the response, Sam. I will try that out ..

My controller is just 600 odd lines (which is quite normal I guess) , but it has lots of conditions (if..else..) .. so thats the reason my test class is going beyound 2000 lines .. and my visual force page is also quite small.