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
Nirupama SharmaNirupama Sharma 

Need Help in writing test class for Future method Apex class


I am new to the Apex development,i have never written  a test class for future method Apex class, can someone plz help me in writing the test class
public class FutureHandler {
    public static void updaterecs(Map<String,Id> oldManagerQuotaMap1){
        Map<Id,Quota__c> oldMapQuota = new Map<Id,Quota__c>();
        if(null != oldManagerQuotaMap1 && oldManagerQuotaMap1.size() > 0){
            for (aggregateResult result: [Select Manager_Quota__c, Sum(Inside_Sales_Roll_Up__c) 
                                          FROM Quota__c WHERE 
                                          Manager_Quota__c IN: oldManagerQuotaMap1.values() 
                                          GROUP BY Manager_Quota__c]) {
                                              system.debug('result'+result)    ;          
                                              oldMapQuota.put((Id)result.get('Manager_Quota__c'),new Quota__c(Id=(Id)result.get('Manager_Quota__c'),Actual_Amount__c =(Decimal)result.get('expr0')));         
            for(Id qId : oldManagerQuotaMap1.values()){
                    oldMapQuota.put(qId, new Quota__c(Id = qId,Actual_Amount__c = 0.0));
            if(null != oldMapQuota && oldMapQuota.size() > 0){
                update oldMapQuota.values();
    public static void sendOppsForApproval(List<Opportunity> opps){
        List<Opportunity> oppsToBeSentForApproval = new List<Opportunity>();
        String monthYear ='MMMM-yyyy');
        String month = monthYear.split('-')[0];
        String year = monthYear.split('-')[1];
        Date nextMonthStart =;
        List<Aggregate_Approval__c> appr = [Select Id from Aggregate_Approval__c where Month__c=:month And Year__c=:year]; 
        Id approvalId;
            approvalId = appr[0].Id;
            for(Opportunity opp : opps){
                opp.Aggregate_Approval__c = approvalId;
                opp.Status__c = 'In Approval';
            update oppsToBeSentForApproval;
           // List<Approval.LockResult> li = Approval.lock(opps);
            Approval.ProcessSubmitRequest oppAggregateApproval = new Approval.ProcessSubmitRequest();
            oppAggregateApproval.setComments('Submitting opportunities for Approval for ''MMMM-yyyy'));
            Approval.ProcessResult approvalResult = Approval.process(oppAggregateApproval); 

Anna lionaAnna liona
I think If you change the method send notification to return a copy of the method you could just call it directly and check the return, If you wish to test the full flow of your code instead of smaller checks on smaller methods will trigger the future call. But with no return from your send notification method without assertions or debugs you would not know if it works.
Nirupama SharmaNirupama Sharma

Can you please elebrote with the sample code snippet please
SFDC Apex DevSFDC Apex Dev
Isn't this question is similar?