FlowTest

Represents the metadata associated with a flow test. Before you activate a record-triggered flow, you can test it to verify its expected results and identify flow run-time failures.

Parent Type

This type extends the Metadata metadata type and inherits its fullName field.

File Suffix and Directory Location

FlowTest components have the suffix .flowtest and are stored in the flowtests folder.

Version

FlowTest components are available in API version 55.0 and later.

Special Access Rules

There are no additional access requirements that are specific to this type.

Fields

Field Name Description
description
Field Type
string
Description
The description of the flow test, such as what it does or how it works.
flowApiName
Field Type
string
Description

Required.

The API name of the flow associated with the flow test.
label
Field Type
string
Description

Required.

The label of the flow test.
testPoints
Field Type
FlowTestPoint[]
Description
An array of test points for the test.

FlowTestPoint

Defines a flow test point that is evaluated when a flow test runs. Each test point is evaluated in the order that it’s listed.

Field Name Description
assertions
Field Type
FlowTestAssertion[]
Description
An array of assertions for the test.
elementApiName
Field Type
string
Description

Required.

The element API names for the start of the flow and the end of the flow.

Possible values are:

  • Start
  • Finish
parameters
Field Type
FlowTestParameter[]
Description
An array of parameters for the test.

FlowTestAssertion

Defines an assertion for a test point that is evaluated when a flow test runs. If one assertion evaluates to false, the test run fails.

Field Name Description
conditions
Field Type
FlowTestCondition[]
Description
An array of conditions for an assertion.
errorMessage
Field Type
string
Description
The custom message that appears in Flow Builder if its associated condition evaluates to false.

FlowTestCondition

Defines a condition for an assertion that is evaluated when a flow test runs. If one condition evaluates to false, the assertion fails.

Field Name Description
leftValueReference
Field Type
string
Description

Required.

The reference to the flow resource that the specified operator applies to.
operator
Field Type
FlowComparisonOperator (enumeration of type string)
Description

Required.

The operation that is applied to the resource reference in the leftValueReference field.

Possible values are:

  • Contains
  • EndsWith
  • EqualTo
  • GreaterThan
  • GreaterThanOrEqualTo
  • HasError—This value is available in API version 64.0 and later.
  • In—This value is available in API version 56.0 and later.
  • IsBlank—This value is available in API version 61.0 and later.
  • IsChanged
  • IsEmpty—This value is available in API version 61.0 and later.
  • IsNull
  • LessThan
  • LessThanOrEqualTo
  • NotEqualTo
  • NotIn—This value is available in API version 56.0 and later.
  • StartsWith
  • WasSelected
  • WasSet
  • WasVisited
rightValue
Field Type
FlowTestReferenceOrValue
Description
The value that the operator applies to the resource reference in the leftValueReference field.

FlowTestReferenceOrValue

Defines a specific value that the operator applies to the resource reference in flow test assertions and conditions.

Field Name Description
booleanValue
Field Type
boolean
Description
Specifies a boolean value.
dateTimeValue
Field Type
dateTime
Description
Specifies a dateTime value.
dateValue
Field Type
date
Description
Specifies a dateValue value.
numberValue
Field Type
double
Description
Specifies a number value.
sobjectValue
Field Type
string
Description
Specifies an sObject value.
stringValue
Field Type
string
Description
Specifies a string value.

FlowTestParameter

Defines parameters for the triggering record in the Start test point.

Field Name Description
leftValueReference
Field Type
string
Description

Required.

The name of the parameter. When type is InputTriggeringRecordInitial or InputTriggeringRecordUpdated, the value for leftValueReference must be $Record. When type is ScheduledPath, the value for leftValueReference must be ScheduledPathApiName.
type
Field Type
FlowTestParameterType (enumeration of type string)
Description

Required.

The type of parameter.

Possible values are:

  • InputTriggeringRecordInitial
  • InputTriggeringRecordUpdated
  • ScheduledPath—Available in API version 56.0 and later.
value
Field Type
FlowTestReferenceOrValue
Description

Required.

The value that the operator applies to the resource reference in the leftValueReference field.

Declarative Metadata Sample Definition

The following is an example of a FlowTest component.

<?xml version="1.0" encoding="UTF-8"?>
<FlowTest xmlns="http://soap.sforce.com/2006/04/metadata">
    <flowApiName>Example_Test</flowApiName>
    <label>Test Two</label>
    <testPoints>
        <elementApiName>Start</elementApiName>
        <parameters>
            <leftValueReference>$Record</leftValueReference>
            <type>InputTriggeringRecordInitial</type>
            <value>
                <sobjectValue>{&quot;AnnualRevenue&quot;:100000,&quot;BillingCity&quot;:&quot;New York&quot;}}</sobjectValue>
            </value>
        </parameters>
        <parameters>
            <leftValueReference>ScheduledPathApiName</leftValueReference>
            <type>ScheduledPath</type>
            <value>Every_Monday</value>
        </parameters>
        <parameters>
            <leftValueReference>$Record</leftValueReference>
            <type>InputTriggeringRecordUpdated</type>
            <value>
                <sobjectValue>{&quot;AnnualRevenue&quot;:100000,&quot;BillingCity&quot;:&quot;New York&quot;}</sobjectValue>
            </value>
        </parameters>
    </testPoints>
    <testPoints>
        <assertions>
            <conditions>
                <leftValueReference>$Record.Industry</leftValueReference>
                <operator>EqualTo</operator>
                <rightValue>
                    <stringValue>Other</stringValue>
                </rightValue>
            </conditions>
            <errorMessage>Industry was not set.</errorMessage>
        </assertions>
        <elementApiName>Finish</elementApiName>
    </testPoints>
</FlowTest>

The following is an example package.xml that references the previous definition.

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>Test_Two</members>
<name>FlowTest</name>
</types>
<version>55.0</version>
</Package>

Wildcard Support in the Manifest File

This metadata type supports the wildcard character * (asterisk) in the package.xml manifest file. For information about using the manifest file, see Deploying and Retrieving Metadata with the Zip File.