• prashanth reddy 129
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
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:
Code:
ApexPages.Message msg;
msg = new ApexPages.Message(ApexPages.Severity.ERROR,'messaggeText');
ApexPages.addMessage(msg);

 
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:
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));

 
How can I test ApexPages.addMessage(msg) instruction in the testerClass?
Best Regards
--
Andrea Rosa