I've created a script in apex that captures the pause reason in a screen flow. In general, I use the FlowRecordRelation and FlowInterview to capture the pause reason and save it to a specific field.
The script is working and now I need to test it.
So I started by trying to insert a flow:
@IsTest private static void testCopyPausedReasonFromFlow() { My_Object__c q = [SELECT Id FROM My_Object__c]; { Map<String, Object> inputs = new Map<String, Object>(); inputs.put('recordId', q.Id); Flow.Interview.My_Object_Flow_V1 myFlow = new Flow.Interview.My_Object_Flow_V1(inputs); myFlow.start(); } } but this didn't work because myFlow.start() threw an error:
System.FlowException: Start can't be called on a flow with the process type Screen Flow.
I then found that the start method only works for autolaunched flow or user provisioning flow per this article.
So my question is:
Is there a way to create FlowInterview and a FlowRecordRelation records in a unit test without doing the above? The documentation is really limited and this is the actual goal here.