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

How do I test a specific page message was added?
i am having trouble finding examples to test something like this...
if ( searchStr.length() < 2 ) { ApexPages.addMessage( new ApexPages.Message( ApexPages.Severity.INFO, 'Search requires more characters')); return null; }
thank you.
How about this:
All Answers
How about this:
In a unit test you would do it like so
yes these work. thank you! jhenning and Tim__m i have a much better understanding now.
IMO, a better way would be to have your page message declared as a constant in the controller class.
Then in your test method you can refrence it directly:
This way if your error message needs changes at some point, you only need to update it in one place.