We have an org where we are using Process Builder to create cases 1 hour after a record have been created with missing data. We are using a scheduled action (Call apex) to do so. We are using the "Call Apex" instead of "Create Record" as the later does not have the functionality to e.g. add fill in Record Types by Name. The functionality seems to be working fine, but we want to include all of our business logic in apex test classes, including this one. When writing the unit test, what I had problem with is to simulate that one hour have passed since the creation of the record. The scheduled process builder action is not running after the the record have been created. First I tought that the scheduled process builder actions are fired after the Test.stopTest() method similarly to scheduled apex but this is not the case. Is there any way to test these scheduled action in apex? Thanks!
1 Answer
The only way I found is to assert the Flow call, after it satisfies the Condition Criteria. See the code below:
List<FlowInterview> flowInterviews = [SELECT Id FROM FlowInterview];
System.assertEquals(1, flowInterviews.size());
Test.stopTest
doesn't work for unit testing.Apex
.