According to my functionality: insert and update calls a trigger that invokes future methods. In my test case, I need to test the update functionality. In order to test the update functionality, I need to first insert the account with appropriate fields. Because of this, the 'after insert' trigger invokes a future method. After this, I am making an 'update' that invokes another future method. Since in one test case , there will be two future methods that will be invoked as a result of 'after insert' and 'update' trigger , How do I test this ? The below function throws an error that seems like invoking 2 future inside a single test case didn't work properly.
Please let me know how I can test this , where am I making mistake ?
Thanking you in advance.
@isTest static void updateOrd(){
Account parentAcc = new Account(name = 'Parent Test Account',
External_Id__c = 'abcd123ee');
Test.startTest();
Test.setMock(HttpCalloutMock.class, new MockHttpChildResponseGenerator());
Account childAcc = new Account(name = 'Test Account', Active__c = true');
insert childAcc;
childAcc.Active__c = false;
Test.setMock(HttpCalloutMock.class, new MockHttpDeactivateResponseGenerator());
update childAcc;
Test.stopTest();
Account updatedChildAcnt = [SELECT External_Id__c from Account where External_Id__c =:'abcd123ee'];
System.assertNotEquals(updatedChildAcnt.Active__c, false);
}