function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
beenerbeener 

Testing for Messages

Hi,

 

I have VisualForce Page with a controller. I am currently writing a test for the code.


Some of the code is designed to return an Apexpages.Message using the Apexpages.addMessage method.

 

My question is how I can verify that this method is created, via the Test Method.

 

Thanks alot,

 

Ben  

bob_buzzardbob_buzzard

Get the map of messages prior to invoking the method that will add a message and capture the size.  Then get it again afterwards and verify that the size has increased.  You can also traverse the map and look for your message.

 

Use ApexPages.getMessages() to retrieve the map.