You need to sign in to do that
Don't have an account?
Steve Chadbourn
Testing Controller Extensions
I'm trying to write unit tests for a controller extension and am getting a Salesforce error when I try and run it.
Here is part of the controller extension I'm trying to test:
Here is the test class:
And here is the error I'm getting when I run it:
I'm guessing its to do with the way I'm passing a standard controller into the controller extansion constructor. I have tried all sorts of different ways to do this without success. Help!
BTW, do I have to test all the action methods that simply return a page?
Here is part of the controller extension I'm trying to test:
Code:
public class newClaimWizardControllerExtension { private final Case new_case; public newClaimWizardControllerExtension(ApexPages.StandardController stdController) { this.new_case = (Case)stdController.getRecord(); } public PageReference policiesPage() { return Page.newClaimWzrdPolicies; } }
Here is the test class:
Code:
public class newClaimWizardControllerExtensionTests { public static testMethod void testMyController() { newClaimWizardControllerExtension controller = new newClaimWizardControllerExtension(new ApexPages.StandardController()); // test page references PageReference policiesPage = controller.policiesPage(); system.assertEquals(policiesPage, Page.newClaimWzrdPolicies); } }
And here is the error I'm getting when I run it:
Code:
An internal server error has occurred An error has occurred while processing your request. The salesforce.com support team has been notified of the problem. If you believe you have additional information that may be of help in reproducing or correcting the error, please contact support@salesforce.com. Please indicate the URL of the page you were requesting, any error id shown on this page as well as any other related information. We apologize for the inconvenience. Thank you again for your patience and assistance. And thanks for using Salesforce! Error ID: 879885452-10
I'm guessing its to do with the way I'm passing a standard controller into the controller extansion constructor. I have tried all sorts of different ways to do this without success. Help!
BTW, do I have to test all the action methods that simply return a page?
My next problem is I'm failing my first, simple test. Here is the code I'm testing:
and here is the test:
and this is the error:
I can't see any difference between the expected and the actual. What am I doing wrong?
That's good news Doug. I look forward to Summer 08.
Any ideas why my unit test is failing?