FlowTestCoverage

Represents test coverage for a flow or process by a given Apex method.

Version 

Introduced in API version 44.0.

Supported SOAP API Calls 

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

Supported REST API Methods 

DELETE, GET, HEAD, PATCH, Query

Fields 

ApexTestClassId 

  • Type: reference

  • Required: No

  • Properties: Filter, Group, Nillable, Sort, Update

  • Description: The ID of the Apex test class.

  • Relationship name: ApexTestClass

  • Relationship type: relationship

  • Refers to: ApexClass

FlowTestId 

  • Type: reference

  • Required: No

  • Properties: Filter, Group, Nillable, Sort, Update

  • Introduced: API version 67.0

  • Relationship name: FlowTest

  • Relationship type: relationship

  • Refers to: FlowTest

FlowVersionId 

  • Type: reference

  • Required: No

  • Properties: Filter, Group, Sort

  • Description: The ID of the flow version that was executed by the test method.

  • Relationship name: FlowVersion

  • Relationship type: masterdetail

  • Refers to: InteractionDefinitionVersion

IsStale 

  • Type: boolean

  • Required: No

  • Properties: Defaulted on create, Filter, Group, Sort, Update

  • Introduced: API version 67.0

  • Default value: false

NumElementsCovered 

  • Type: int

  • Required: No

  • Properties: Filter, Group, Nillable, Sort, Update

  • Description: The number of elements that were executed by the test method.

NumElementsNotCovered 

  • Type: int

  • Required: No

  • Properties: Filter, Group, Nillable, Sort, Update

  • Description: The number of elements that weren’t executed by the test method.

TestMethodName 

  • Type: string

  • Required: No

  • Properties: Filter, Group, Nillable, Sort, Update

  • Description: The name of the Apex method that executed the flow version.

Usage 

To deploy a process or autolaunched flow as active in production orgs, you must meet the flow test coverage requirement for your org. At least one Apex test must cover the flow test coverage percentage of the active processes and autolaunched flows. Flow test coverage requirements don’t apply to flows that have screens. 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 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'

DID THIS ARTICLE SOLVE YOUR ISSUE?
Let us know so we can improve!