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
karthic sankar 9karthic sankar 9 

how to write unittest method for below method

Hi Experts,

Please let me know how to write unit test method for below.

  public List<AggregateResult> BadgeList
          List<AggregateResult> badges = [select Week__c, max(createddate) apple from QAAM_Weekly_Planner__c Max group by Week__c order by max(createddate) desc LIMIT 10];
          return badges;

Karthic Sankar V P
Best Answer chosen by karthic sankar 9
David Zhu 🔥David Zhu 🔥
You may refer the code below:

static testmethod void testBadgeList()
       LIst<QAAM_Weekly_Planner__c> planners = new List<QAAM_Weekly_Planner__c>();

       Intger total = 10;
       for (integer i= 0;i<total;i++)
             QAAM_Weekly_Planner__c  planner = new QAAM_Weekly_Planner__c ();
             planner.Week__c = .....    // put test value;
              planner.otherfields__c = ...   //put other madatory fields
       insert planners;

        List<AggregateResult> BadgeList = yourTestClassName.BadgeList;
        System.assert(BadgeList.size() > 0);