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
kabkab 

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

ApexPages.addMessage(myMsg);

return null;

 

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

 

mtbclimbermtbclimber

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.