Skip to main content
4 of 4
added 318 characters in body
Priyalakshmi
  • 1.5k
  • 2
  • 21
  • 40

how to write a test class for trigger that calls future method?

trigger CaseTri on Case (after insert) {
    if(Trigger.isAfter){
        if(Trigger.isUpdate){
             if(classA.Method1){    
                webServices.notify(Trigger.New[0].Id);
                ClassA.Method1 = true;                
             }
        }
        if(Trigger.isAfter){
            if(Trigger.isInsert){
                if(ClassA.method1) {  
                    webservice.CcNotification(Trigger.New[0].Id);
                    ClassA.method1 = true;
                }
            }
        }

webservice.CcNotification(Trigger.New[0].Id);->line which calls future method

My testclass:

@isTest(SeeAllData=true)
public class CaseTri{
public static testMethod void testnotif(){
Case c = new Case();
insert c;
Test.startTest();
Test.setMock(WebServiceMock.class, new WebServiceMockImplnotif());

  
  Test.stopTest();
}
}
Priyalakshmi
  • 1.5k
  • 2
  • 21
  • 40