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
shravani milshravani mil 

unable to cover @future method in test class

unable to cover this method in my test class

    @future (callout=true)
    public static void syncToS(Set<Id> oppIDs){
        
        List<Log__c> errLogs = new List<Log__c>();
        
        for (Id oppId : oppIDs) {
            try {
                GenerateOpptyStageSync.OpptyStageSync(String.valueOf(oppId),'');
            }
            catch(Exception ex) {
               ()
            }
        }
      
        if (errLogs.size() > 0)
            insert errLogs;
    }
    
Akshay_DhimanAkshay_Dhiman
Hi Shravani,
Put call to the future method inside startTest/stopTest:
Test.startTest();
myClass.futuremethod( someID ); // here the OppIds
Test.stopTest();
Remember , Test.stopTest() does not return until your future method has completed.
Hope this will help you.
Regards,
Akshay