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

How to write a test class for starting a flow in apex?

I want to try to bulkify a headless flow using an apex batch job to call it every hour, but I can't find anything on how to write a test class for a batch that only calls a flow. Has anyone tried to do this? Are there any gotchas you ran into with the flow?
James LoghryJames Loghry

Awesome question.  Headless flows are pretty similar to Apex Triggers in terms of functionality, so my educated guess is that you could test a headless flow the same way you would test a trigger.  In other words, you could insert records and/or update the records to assert your flow is working properly.  For bulk conditions, you could create / update several records at once to prove your Flow is working properly.
Brannonk, can I ask how you were able to use an apex batch job to start a flow? I'm having issues to try and get that portion working.  Any help would be appreciated.