You need to sign in to do that
Don't have an account?
AndreaRoz
Error: ApexPages.addMessage can only be called from a VF page
Hi to all,
I have got a page with a custom controller, inside the controller I use the "addMessage" to display custom message to the user:
I created my tester class and but when I run test there is following error:
ApexPages.addMessage can only be called from a VisualForce page, following the piece of code of my testerClass:
How can I test ApexPages.addMessage(msg) instruction in the testerClass?
Best Regards
--
Andrea Rosa
I have got a page with a custom controller, inside the controller I use the "addMessage" to display custom message to the user:
Code:
ApexPages.Message msg; msg = new ApexPages.Message(ApexPages.Severity.ERROR,'messaggeText'); ApexPages.addMessage(msg);
ApexPages.addMessage can only be called from a VisualForce page, following the piece of code of my testerClass:
Code:
PageReference pageRef = Page.FilialeAssegnazione; Test.setCurrentPageReference(pageRef); pageRef.getParameters().put('id',MyCase.Id); queueController controller; ApexPages.StandardController stdController; controller = new queueController(new ApexPages.StandardController(MyCase));
Best Regards
--
Andrea Rosa
Hi Simba,
unfortunately I haven't found a solution for this problem, I am able to pass the test because I created my testMethod so that the line with addMessage instruction is not executed, as you can see this is not a valid solution, please let me know if you fix that problem.
Best
--
Andrea Rosa
Please refer the link to resolve issue.
http://annappaph.blogspot.com/2017/01/salesforce-finalexception-apexpages.html
Thanks
Prashanth