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
keerthana chowdharykeerthana chowdhary 

how to do unit test

 ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'account = null'));


my test code
 List<Apexpages.Message> pageMessages = ApexPages.getMessages();
    System.assertNotEquals(0, pageMessages.size());

// Check that the error message you are expecting is in pageMessages
Boolean messageFound = false;

for(ApexPages.Message message : pageMessages) {
    if(message.getSummary() == 'Your summary'
        && message.getDetail() == 'Your detail'
        && message.getSeverity() == ApexPages.severity.ERROR) {
        messageFound = true;        
    }
}

but iwas unable to cover these line any help