You need to sign in to do that
Don't have an account?

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
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.