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
pjaenickepjaenicke 

After Update Timing issue with Test Class

Greetings !

 

Wondering how to solve what I think is just a timing issue..

 

I have an "After Update" trigger that inserts records into a child object.

 

Seems to work fine when run and inspected by human eyes, however, in my test class, I think I'm running into an issue where my "after update" hasn't quite finished yet. 

 

How can I ensure the trigger has finished processing before my "assertEquals" checks in my test class?

 

Thanks,

Pete

 

skodisanaskodisana

Hi,

 

In your test class do an Update DML statement like insert, So that after update event will get fire and code will be covered.

 

Thanks,

kodisana

BritishBoyinDCBritishBoyinDC

wrap the update statement in the test class in a test.start/test.stop sequence. When the test sees stoptest(), it runs all actions including after updates and workflows, and then when you query for the object, it should be correct:

 

e.g. 

 

 

test.starttest();
update [your object];
test.stoptest();