You need to sign in to do that
Don't have an account?
testing coverage for a controller extension
static testMethod void AssetAtRiskTest(){
Account acc = new Account(name = 'foo');
insert acc;
ApexPages.StandardController sc = new ApexPages.StandardController(acc);
PageReference pageRef = sc.view();
AssetAtRisk a = new AssetAtRisk(sc);
test.startTest();
test.setCurrentPage(pageRef);
pageRef = a.autoRun();
test.stopTest();
}
so this is my test code minus the assertions of course. The issue is that when the autorun function is running the following line always produces null.
String theId = ApexPages.currentPage().getParameters().get('id');
I would expect this line to set theId to the Id of the new account I created in the test method, however this is not the case. Am I missing something simple here?
you can set the parameters for the page using this line of code
So, the test class will be
Let me know if it worked..
All Answers
you can set the parameters for the page using this line of code
So, the test class will be
Let me know if it worked..
Thanks Edwin,
That line of code worked perfectly, you just have to make you change the current page before you set the Id.