Track Process and Flow Test Coverage

If your org uses Apex tests to validate processes and autolaunched flows, you’re probably interested in knowing what your flow test coverage is. We’re introducing two Tooling API objects that you can query to calculate test coverage for processes and autolaunched flows.

Where: This change applies to Lightning Experience and Salesforce Classic in Essentials, Professional, Enterprise, Performance, Unlimited, and Developer editions.

Why: When you deploy an active process or flow, Salesforce runs your org’s Apex tests and confirms that enough of your processes and flows have test coverage.

How: FlowTestCoverage represents test coverage for a flow by an Apex test method. FlowElementTestCoverage records are created when an Apex test method executes a flow element.

To calculate the overall test coverage for a flow version, query the FlowTestCoverage object. The FlowElementTestCoverage object is not used to calculate test coverage.

SELECT Id, ApexTestClassId, TestMethodName, FlowVersionId, NumElementsCovered, NumElementsNotCovered 
FROM FlowTestCoverage 
WHERE flowversionid='301RM0000004GiK'

To get information about the elements executed by a test run, query the FlowElementTestCoverage object. For example, this query returns the number of unique elements that have been executed.

SELECT count_distinct(ElementName) 
FROM FlowElementTestCoverage 
WHERE FlowVersionId='301RM0000004GiK'

Related Updates for Developers

Tooling API
New objects: FlowTestCoverage, FlowElementTestCoverage