+ Start a Discussion

Help Code Coverage for the following

This is not inside visualforce controller it is a independent class

ApexPages.Message myMsg =

new ApexPages.Message(ApexPages.Severity.ERROR, message Text);


return null;


How can I add code coverage for the following apex.code?



I think you mean "how do I assert this" not cover it, right?


If so you'll need to leverage one of the methods listed here in the visualforce documentation.


If you just need to make sure there's a message call hasMessage() or if you need to make sure it's an error try the variation with the severity enum as an arg. If you need to assert the text you'll need to use getMessages and iterate over them.