You need to sign in to do that
Don't have an account?

Quick PageRef Test Question
Im working on a part of a class that creates a wizard but I cant successfully write a test code for it. I have one below and I cant understand why it doesnt work. Why wont this code work?
Heres the part of the class that needs testing-
public PageReference step1() { return Page.mhform1; } public PageReference step2() { return Page.mhform2; } public PageReference step3() { return Page.mhform3; } public PageReference step4() { return Page.mhformconfirm; }
Heres what I have made for a test code so far-
@isTest private class testGLeadExtention { static testMethod void step1Test() { // TO DO: implement unit test PageReference step1 = Page.mhform1; Test.setCurrentPageReference(step1); } static testMethod void step2Test() { // TO DO: implement unit test PageReference step2 = Page.mhform2; Test.setCurrentPageReference(step2); } static testMethod void step3Test() { // TO DO: implement unit test PageReference step3 = Page.mhform3; Test.setCurrentPageReference(step3); } static testMethod void step4Test() { // TO DO: implement unit test PageReference step4 = Page.mhformconfirm; Test.setCurrentPageReference(step4); } }
A bit out of my element, but I believe you need to instantiate an instance of the controller. Here's how I got mine to pass for a campaign member controller extension which gets variables from the URL:
There's a great guide on visualforce tests here.
Scroll down to find the section on apex controllers.