FlowTest

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

Parent Type 

This type extends Metadata and inherits its fields.

File Suffix and Directory Location 

FlowTest components have the suffix .flowtest, and Salesforce stores them in the flowtests folder.

Version 

Introduced in API version 55.0.

Special Access Rules 

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

Fields 

description 

  • Type: string
  • Required: No
  • Description: The description of the flow test, such as what it does or how it works.

doesCommitChanges 

  • Type: boolean
  • Required: No

doesSkipStartConditions 

  • Type: boolean
  • Required: No

doesTestWaitElement 

  • Type: boolean
  • Required: No

flowApiName 

  • Type: string

  • Required: Yes

  • Description: Required.

    The API name of the flow associated with the flow test.

flowTestDataSources 

  • Type: FlowTestDataSource[]
  • Required: No
  • Introduced: API version 66.0
  • Description: An array of data sources for the flow test of a record-triggered flow or an autolaunched flow.

flowTestFlowVersions 

  • Type: FlowTestFlowVersion[]
  • Required: No
  • Introduced: API version 66.0
  • Description: An array of flow versions that are associated with the flow test.

isolatedObjectExternalKeys 

  • Type: FlowTestIsolObjExtlKey[]
  • Required: No
  • Introduced: API version 66.0
  • Description: An array of isolated objects and the key fields that uniquely identify each record for the flow test of a record-triggered flow or an autolaunched flow.

isSubflowUseLatestFlowVer 

  • Type: boolean
  • Required: No

label 

  • Type: string

  • Required: Yes

  • Description: Required.

    The label of the flow test.

runTestAsUser 

  • Type: string
  • Required: No

testPoints 

  • Type: FlowTestPoint[]
  • Required: No
  • Description: An array of test points for the test.

testType 

  • Type: FlowTestType (enumeration of type string)

  • Required: No

  • Introduced: API version 66.0

  • Description: Required.

    Specifies whether the test contains assertions.

  • Possible values:

    • WithAssertion — The automated comparison of the actual flow outcome with the user-defined expected outcome that assertions define.

FlowTestAssertion Type 

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

Fields 

conditions 

errorMessage 

  • Type: string
  • Required: No
  • Description: If the associated condition evaluates to false, this custom message appears in Flow Builder.

FlowTestCondition Type 

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

Fields 

leftValueReference 

  • Type: string

  • Required: Yes

  • Description: Required.

    The reference to the flow resource that the specified operator applies to.

operator 

  • Type: FlowComparisonOperator (enumeration of type string)

  • Required: Yes

  • Description: Required.

    The flow test uses this value to evaluate the resource reference in the leftValueReference field. The date comparison operators, such as IsAfter, IsBefore, and IsOn, apply to Date fields only, not DateTime fields.

  • Possible values:

    • Contains
    • EndsWith
    • EqualTo
    • GreaterThan
    • GreaterThanLastNumberOfDays — Returns true if the date value is more than N days before today. If N is a decimal, only the integer portion is used. This value is available in API version 67.0 and later.
    • GreaterThanOrEqualTo
    • HasError — This value is available in API version 64.0 and later.
    • HasNoValue — Returns true if the date value has no value. This value is available in API version 67.0 and later.
    • HasValue — Returns true if the date value has a value. This value is available in API version 67.0 and later.
    • In — This value is available in API version 56.0 and later.
    • IsAfter — Returns true if the date value is after the specified date. This value is available in API version 67.0 and later.
    • IsAnniversaryOfToday — Returns true if the month and day of the date value match today’s month and day. This value is available in API version 67.0 and later.
    • IsBefore — Returns true if the date value is before the specified date. This value is available in API version 67.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.
    • IsLastMonth — Returns true if the date value falls within the previous calendar month. This value is available in API version 67.0 and later.
    • IsNextMonth — Returns true if the date value falls within the next calendar month. This value is available in API version 67.0 and later.
    • IsNotAnniversaryOfToday — Returns true if the month and day of the date value don’t match today’s month and day. This value is available in API version 67.0 and later.
    • IsNull
    • IsOn — Returns true if the date value is the same as the specified date. This value is available in API version 67.0 and later.
    • IsThisMonth — Returns true if the date value falls within the current calendar month. This value is available in API version 67.0 and later.
    • IsToday — Returns true if the date value is today’s date. This value is available in API version 67.0 and later.
    • IsTomorrow — Returns true if the date value is tomorrow’s date. This value is available in API version 67.0 and later.
    • IsYesterday — Returns true if the date value is yesterday’s date. This value is available in API version 67.0 and later.
    • LastNumberOfDays — Returns true if the date value falls within the last N days, including today. If N is a decimal, only the integer portion is used. This value is available in API version 67.0 and later.
    • LastNumberOfMonths — Returns true if the date value falls within the last N calendar months, excluding the current month. If N is a decimal, only the integer portion is used. This value is available in API version 67.0 and later.
    • LastNumberOfYears — Returns true if the date value falls within the last N calendar years, excluding the current year. If N is a decimal, only the integer portion is used. This value is available in API version 67.0 and later.
    • LastYear — Returns true if the date value falls within the previous calendar year. This value is available in API version 67.0 and later.
    • LessThan
    • LessThanOrEqualTo
    • NextNumberOfDays — Returns true if the date value falls within the next N days, including today. If N is a decimal, only the integer portion is used. This value is available in API version 67.0 and later.
    • NextNumberOfMonths — Returns true if the date value falls within the next N calendar months, excluding the current month. If N is a decimal, only the integer portion is used. This value is available in API version 67.0 and later.
    • NextYear — Returns true if the date value falls within the next calendar year. This value is available in API version 67.0 and later.
    • NotEqualTo
    • NotIn — This value is available in API version 56.0 and later.
    • StartsWith
    • ThisYear — Returns true if the date value falls within the current calendar year. This value is available in API version 67.0 and later.
    • WasSelected
    • WasSet
    • WasVisited

rightValue 

  • Type: FlowTestReferenceOrValue
  • Required: No
  • Description: The value that the operator applies to the resource reference in the leftValueReference field.

FlowTestDataSource Type 

Defines the data source for a flow test of a record-triggered flow or an autolaunched flow. This subtype is available in API version 66.0 and later.

Fields 

apexClass 

  • Type: string

  • Required: No

  • Description: Required.

    The Apex class associated with the data source when dataSourceType is ApexClass.

dataSourceType 

  • Type: FlowTestDataSourceType (enumeration of type string)

  • Required: Yes

  • Description: Required.

    The data source type for the flow test.

    Possible value is ApexClass.

testDataJson 

  • Type: string
  • Required: No

FlowTestExtKeyField Type 

Defines the external key fields that identify the unique records in isolated test data for a record-triggered flow or an autolaunched flow. This subtype is available in API version 66.0 and later.

Fields 

fieldName 

  • Type: string

  • Required: Yes

  • Description: Required.

    The field API name to identify the unique records to test.

FlowTestFlowVersion Type 

Defines the flow version for the flow test. This subtype is available in API version 66.0 and later.

Fields 

flowVersionNumber 

  • Type: string
  • Required: Yes
  • Description: The version number of the flow version that’s associated with the flow test.

FlowTestIsolObjExtlKey Type 

Defines an external isolated object and the fields that identify unique records to test for a record-triggered flow or an autolaunched flow. This subtype is available in API version 66.0 and later.

Fields 

keyFields 

  • Type: FlowTestExtKeyField[]
  • Required: No
  • Description: The key fields that identify unique records to test. Don’t use fields of the lookup data type.

objectType 

  • Type: string

  • Required: Yes

  • Description: Required.

    The object type of the isolated data to test.

FlowTestParameter Type 

Defines parameters for the triggering record, flow path, and input variable in the Start test point.

Fields 

leftValueReference 

  • Type: string

  • Required: Yes

  • 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 

  • Type: FlowTestParameterType (enumeration of type string)

  • Required: Yes

  • Description: Required.

    The type of parameter.

  • Possible values:

    • InputTriggeringRecordInitial
    • InputTriggeringRecordUpdated
    • InputVariable — This value is available in API version 66.0 and later.
    • ScheduledPath — Available in API version 56.0 and later.

value 

  • Type: FlowTestReferenceOrValue

  • Required: Yes

  • Description: Required.

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

FlowTestPoint Type 

Defines a flow test point that Salesforce evaluates when a flow test runs. Salesforce evaluates each test point in the order that it’s listed.

Fields 

assertions 

elementApiName 

  • Type: string (enumeration of type string)

  • Required: Yes

  • Description: Required.

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

  • Possible values:

    • Start
    • Finish

isUseMockOutput 

  • Type: boolean
  • Required: No

parameters 

pathAfterMockOutput 

  • Type: string
  • Required: No

FlowTestReferenceOrValue Type 

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

Fields 

booleanValue 

  • Type: boolean
  • Required: No
  • Description: Specifies a boolean value.

collectionElements 

dateTimeValue 

  • Type: dateTime
  • Required: No
  • Description: Specifies a dateTime value.

dateValue 

  • Type: date
  • Required: No
  • Description: Specifies a dateValue value.

elementReference 

  • Type: string
  • Required: No
  • Description: Reserved for future use.

jsonValue 

  • Type: string
  • Required: No
  • Introduced: API version 66.0
  • Description: Specifies a JSON value for the isolated test data record.

numberValue 

  • Type: double
  • Required: No
  • Description: Specifies a number value.

sobjectValue 

  • Type: string
  • Required: No
  • Description: Specifies an sObject value.

stringValue 

  • Type: string
  • Required: No
  • Description: Specifies a string value.

timeValue 

  • Type: xsd:time
  • Required: No
  • Description: Specifies a time value.

Declarative Metadata Sample Definition 

The following is an example of a FlowTest component.

1<?xml version="1.0" encoding="UTF-8"?>
2<FlowTest xmlns="http://soap.sforce.com/2006/04/metadata">
3    <flowApiName>Example_Test</flowApiName>
4    <label>Test Two</label>
5    <testPoints>
6        <elementApiName>Start</elementApiName>
7        <parameters>
8            <leftValueReference>$Record</leftValueReference>
9            <type>InputTriggeringRecordInitial</type>
10            <value>
11                <sobjectValue>{&quot;AnnualRevenue&quot;:100000,&quot;BillingCity&quot;:&quot;New York&quot;}}</sobjectValue>
12            </value>
13        </parameters>
14        <parameters>
15            <leftValueReference>ScheduledPathApiName</leftValueReference>
16            <type>ScheduledPath</type>
17            <value>Every_Monday</value>
18        </parameters>
19        <parameters>
20            <leftValueReference>$Record</leftValueReference>
21            <type>InputTriggeringRecordUpdated</type>
22            <value>
23                <sobjectValue>{&quot;AnnualRevenue&quot;:100000,&quot;BillingCity&quot;:&quot;New York&quot;}</sobjectValue>
24            </value>
25        </parameters>
26    </testPoints>
27    <testPoints>
28        <assertions>
29            <conditions>
30                <leftValueReference>$Record.Industry</leftValueReference>
31                <operator>EqualTo</operator>
32                <rightValue>
33                    <stringValue>Other</stringValue>
34                </rightValue>
35            </conditions>
36            <errorMessage>Industry was not set.</errorMessage>
37        </assertions>
38        <elementApiName>Finish</elementApiName>
39    </testPoints>
40</FlowTest>

For isolated test data sample:

1<?xml version="1.0" encoding="UTF-8"?>
2<FlowTest xmlns="http://soap.sforce.com/2006/04/metadata">
3    <flowApiName>Example_Test</flowApiName>
4    <label>Test Two</label>
5    <flowTestDataSources>
6        <apexClass>FlowTestDataFactory</apexClass>
7        <dataSourceType>ApexClass</dataSourceType>
8    </flowTestDataSources>
9    <flowTestFlowVersions>
10        <flowVersionNumber>1</flowVersionNumber>
11    </flowTestFlowVersions>   
12    <isolatedObjectExternalKeys>
13        <keyFields>
14            <fieldName>Phone</fieldName>
15        </keyFields>
16        <objectType>Account</objectType>
17    </isolatedObjectExternalKeys>
18    <testPoints>
19        <elementApiName>Start</elementApiName>                  
20        <parameters>
21            <leftValueReference>Accounts</leftValueReference>
22            <type>InputVariable</type>
23            <value>
24                <jsonValue>{&quot;fields&quot;:{&quot;Phone&quot;:&quot;4155551212&quot;},&quot;attributes&quot;:{&quot;type&quot;:&quot;Account&quot;}}</jsonValue>
25            </value>
26        </parameters>
27    </testPoints>
28    <testPoints>
29        <assertions>
30            <conditions>
31                <leftValueReference>Accounts.Phone</leftValueReference>
32                <operator>EqualTo</operator>
33                <rightValue>
34                    <stringValue>4155551212</stringValue>
35                </rightValue>
36            </conditions>         
37            <errorMessage>Account not found.</errorMessage>
38        </assertions>
39        <elementApiName>Finish</elementApiName>
40    </testPoints>
41    <testType>WithAssertion</testType>
42</FlowTest>

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

1<?xml version="1.0" encoding="UTF-8"?>
2<Package xmlns="http://soap.sforce.com/2006/04/metadata">
3<types>
4<members>Test_Two</members>
5<name>FlowTest</name>
6</types>
7<version>66.0</version>
8</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.