Newer Version Available

This content describes an older version of this product. View Latest

FlowTestCoverage

Represents test coverage for a flow or process by a given Apex method. Available in API version 44.0 and later.

Supported SOAP Calls

delete(), describeSObjects(), query(), retrieve(), update()

Supported REST HTTP Methods

GET, HEAD

Fields

Field Details
ApexTestClassId
Type
ID
Properties
Filter, Group, Sort, Update
Description
The ID of the Apex test class.
FlowVersionId
Type
ID
Properties
Filter, Group, Sort
Description
The ID of the flow version that was executed by the test method.
NumElementsCovered
Type
int
Properties
Filter, Group, Nillable, Sort, Update
Description
The number of elements that were executed by the test method.
NumElementsNotCovered
Type
int
Properties
Filter, Group, Nillable, Sort, Update
Description
The number of elements that weren’t executed by the test method.
TestMethodName
Type
string
Properties
Filter, Group, Nillable, Sort, Update
Description
The name of the Apex method that executed the flow version.

Usage

FlowTestCoverage records are deleted when changes are saved to the associated flow version.

A flow version corresponds to a process built in Process Builder or a flow built in Flow Builder. For a process, Apex tests execute only the active version. For a flow, Apex tests execute the active version. When a flow has no active version, Apex tests execute the latest version.

Make sure that Deploy processes and flows as active is enabled in your org’s process automation settings. Otherwise, when you deploy active flows and processes via change sets or Metadata API, they’re deployed as inactive.

Tip

To deploy a process or flow as active, your org must have 75% flow test coverage. To calculate your org’s flow test coverage, Salesforce divides the number of covered flows and processes by the sum of the number of active processes and active autolaunched flows.

Sample Query

Get the names of all flows and processes that have test coverage.

1SELECT FlowVersion.Definition.DeveloperName
2FROM FlowTestCoverage
3GROUP BY FlowVersion.Definition.DeveloperName

Get the names of all active autolaunched flows and processes that don’t have test coverage.

1SELECT Definition.DeveloperName
2FROM Flow
3WHERE Status = 'Active'
4      AND (ProcessType = 'AutolaunchedFlow' OR ProcessType = 'Workflow' OR ProcessType = 'CustomEvent' OR ProcessType = 'InvocableProcess')
5      AND Id NOT IN (SELECT FlowVersionId FROM FlowTestCoverage)

Get overall test coverage for a flow version.

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