+ 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