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
ramm12ramm12 

Need help on apex test class

Hi ,

I have the below two list

Issue 1:

Public List<Opportunity> test{get;set;}
Public List<AggregateResult> test1{get;set;}

if(test.size()>0 && test1.size()==0)
{
//some code
}

Issue 2:


ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO,'this is not valid.'));

How to write and cover the above two issues in apex test class??



SRKSRK
As the Opportunity List is public you can access the list in test class

like you have a class A the create a Object of class A in test class and then access the list using ObjOfClassA.test.add(TempOpportunityRecordCreatedinTestClass)
and thenn call your method
ramm12ramm12
can you send the sample code to cover as well for cover the below line ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO,'this is not valid.'));