You need to sign in to do that
Don't have an account?

test class insert records with delay
Hi,
I have written a trigger in which fields are updated based on previous record. In the test class thus i need to insert 2 records with a delay in between them. So that the 1st record is created and based on that the next record should be updated.
Thanks in advance!
I have written a trigger in which fields are updated based on previous record. In the test class thus i need to insert 2 records with a delay in between them. So that the 1st record is created and based on that the next record should be updated.
Thanks in advance!
Below codes help you but you have mentioned wrong function i supposed
IF it helps you than please mark it as a solution and ENJOY APEX
All Answers
Hi,
Rajendra said correct we don't any delay method in APEX langauge. If you mentioned your code here and condation what actually wants then we can help you.
Thanks
@isTest
public class TestRoundRobin2Inc {
public static void insertOneNewIncident() {
BMCServiceDesk__Incident__c inc1 = new BMCServiceDesk__Incident__c();
inc1.BMCServiceDesk__FKClient__c='005o0000000FprNAAS';
inc1.BMCServiceDesk__FKCategory__c='a17o0000000QvkOAAS';
inc1.OwnerId='00Go0000000o2dfEAA';
insert inc1;
}
//*******inserting 2nd incident record which should be inserted after the 1st recod has been inserted, but both of them are getting inserted simultaneuously.
static testMethod void insertTwoNewIncident() {
BMCServiceDesk__Incident__c inc2 = new BMCServiceDesk__Incident__c();
inc2.BMCServiceDesk__FKClient__c='005o0000000FprNAAS';
inc2.BMCServiceDesk__FKCategory__c='a17o0000000QvkOAAS';
inc2.OwnerId='00Go0000000o2dfEAA';
insert inc2;
TestRoundRobin.insertNewIncident();
}
}
Below codes help you but you have mentioned wrong function i supposed
IF it helps you than please mark it as a solution and ENJOY APEX
But i am getting only 36% code coverage and the code lines where the secord record is being update based on the first one are in Red showing they were not covered.