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
FabienHuotFabienHuot 

Winter'19 : Flow and Test coverage

Hi everybody,

Since the Winter'19, there are some things I really don't understand with "Flows" and Test corevage.

From Salesforce's doc here : https://sforce.co/2PqALZw

"For example, if you have 10 active autolaunched flows and processes, and 8 of them have test coverage, your org’s flow test coverage is 80%."

How can we test "Flows", or the real question is : How Salesforce test flow ?. How can I visualize if my flow is coreved.

This query below is used to know which of my flows are not covered.
SELECT Definition.DeveloperName
FROM Flow
WHERE Status = 'Active' 
   AND (ProcessType = 'AutolaunchedFlow' 
      OR ProcessType = 'Workflow' 
      OR ProcessType = 'CustomEvent' 
      OR ProcessType = 'InvocableProcess') 
   AND Id NOT IN (SELECT FlowVersionId FROM FlowTestCoverage)

When executing this query, Salesforce tells me that I have some flow not covered, but how can I cover them?
How Salesforce decide if my flow is covered or not ?

Thanks for your help :)
sagar jogisagar jogi
It is depend on your test class. If your test class are executing the flow/process builder than it will cover the coverage for FlowTestCoverage.
Please see attached link - https://releasenotes.docs.salesforce.com/en-us/winter19/release-notes/rn_forcecom_flow_test_coverage.htm

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future.

Thanks and Regards,
Sagar Jogi

 
Agustina GarciaAgustina Garcia

Hi Sagar, 

And how can I create a test that covers my flow. For instance. I have an autolaunched flow. Everytime I modify a record of my customObject__c, a trigger checks if a field has a certain value. If so, it calls the flow. 
My first thought was to create a test class that covers the trigger. Basically I just create a record with the expected value. 

Now, if I run the query:

SELECT Id, ApexTestClassId, TestMethodName, FlowVersionId, NumElementsCovered, NumElementsNotCovered 
FROM FlowTestCoverage WHERE flowversionid ='301B0000000L4mHIAS'
I get a new record that shows my test class. 

However if I run:
SELECT Definition.DeveloperName
FROM Flow
WHERE Status = 'Active' 
   AND (ProcessType = 'AutolaunchedFlow' 
      OR ProcessType = 'Workflow' 
      OR ProcessType = 'CustomEvent' 
      OR ProcessType = 'InvocableProcess') 
   AND Id NOT IN (SELECT FlowVersionId FROM FlowTestCoverage)
the autolaunched flow appears, so really confused.

On the other side, shall I guess that there is no way to test "Screen Flow" flows?

Thanks!!
 
Agustina GarciaAgustina Garcia
It seems my org was a bit crazy because I moved my autolaunched flow, trigger and test to a new org and it worked fine. The first quey returns 1 as NumElementsCovered and 0 as NumElementsNotCovered, and the second query does not cotain my flow anymore.

Thanks!!