---
schema_version: "1"
id: 1ea980a692ce60ab88223130836362544ff79ee02814495e059c079d89737f2f
title: FlowTest
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/api_meta/meta_flowtest.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_flowtest.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: c3828a58a0dd356094b2914e9a6a46b586798d7227b80853671b03d4692c917e
description: 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.
---
# 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 the [Metadata](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/metadata.htm "The base class for all metadata types. You can’t edit this object. A component is an instance of a metadata type.") metadata type and inherits its fullName field.

## File Suffix and Directory Location

FlowTest components have the suffix .flowtest, and Salesforce stores them 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.



 |
| flowTestDataSources | 

Field Type

[FlowTestDataSource](#subtype_FlowTestDataSource)\[\]

Description

An array of data sources for the flow test of a record-triggered flow or an autolaunched flow. This field is available in API version 66.0 and later.



 |
| flowTestFlowVersions | 

Field Type

[FlowTestFlowVersion](#subtype_FlowTestFlowVersion)\[\]

Description

An array of flow versions that are associated with the flow test. This field is available in API version 66.0 and later.



 |
| isolatedObjectExternalKeys | 

Field Type

[FlowTestIsolObjExtlKey](#subtype_FlowTestIsolObjExtlKey)\[\]

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. This field is available in API version 66.0 and later.



 |
| label | 

Field Type

string

Description

Required.

The label of the flow test.



 |
| testPoints | 

Field Type

[FlowTestPoint](#subtype_FlowTestPoint)\[\]

Description

An array of test points for the test.



 |
| testType | 

Field Type

FlowTestType (enumeration of type string)

Description

Required.

Specifies whether the test contains assertions. This field is available in API version 66.0 and later.

Possible values are:

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





 |

## FlowTestFlowVersion

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

| Field Name | Description |
| --- | --- |
| flowVersionNumber | 
Field Type

string

Description

The version number of the flow version that’s associated with the flow test.



 |

## FlowTestDataSource

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.

| Field Name | Description |
| --- | --- |
| apexClass | 
Field Type

string

Description

Required.

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



 |
| dataSourceType | 

Field Type

FlowTestDataSourceType (enumeration of type string)

Description

Required.

The data source type for the flow test.

Possible value is ApexClass.





 |

## FlowTestIsolObjExtlKey

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.

| Field Name | Description |
| --- | --- |
| keyFields | 
Field Type

[FlowTestExtKeyField](#subtype_FlowTestExtKeyField)\[\]

Description

The key fields that identify unique records to test. Don’t use fields of the lookup data type.



 |
| objectType | 

Field Type

string

Description

Required.

The object type of the isolated data to test.



 |

## FlowTestExtKeyField

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.

| Field Name | Description |
| --- | --- |
| fieldName | 
Field Type

string

Description

Required.

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



 |

## FlowTestPoint

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.

| Field Name | Description |
| --- | --- |
| assertions | 
Field Type

[FlowTestAssertion\[\]](#subtype_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





 |
| isUseMockOuput | Reserved for future use. |
| parameters | 

Field Type

[FlowTestParameter\[\]](#subtype_FlowTestParameter)

Description

An array of parameters for the test.



 |

## FlowTestAssertion

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.

| Field Name | Description |
| --- | --- |
| conditions | 
Field Type

[FlowTestCondition\[\]](#subtype_FlowTestCondition)

Description

An array of conditions for an assertion.



 |
| errorMessage | 

Field Type

string

Description

If the associated condition evaluates to false, this custom message appears in Flow Builder.



 |

## FlowTestCondition

Defines a condition for an assertion that Salesforce evaluates 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 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 are:

- 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 | 

Field Type

[FlowTestReferenceOrValue](#subtype_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.



 |
| elementReference | Reserved for future use. |
| jsonValue | 

Field Type

string

Description

Specifies a JSON value for the isolated test data record. This field is available in API version 66.0 and later.



 |
| 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.



 |
| timeValue | 

Field Type

time

Description

Specifies a time value.



 |

## FlowTestParameter

Defines parameters for the triggering record, flow path, and input variable 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
- InputVariable—This value is available in API version 66.0 and later.
- ScheduledPath—Available in API version 56.0 and later.





 |
| value | 

Field Type

[FlowTestReferenceOrValue](#subtype_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\>

For isolated test data sample:

<?xml version="1.0" encoding="UTF-8"?>
<FlowTest xmlns="http://soap.sforce.com/2006/04/metadata">
    <flowApiName\>Example\_Test</flowApiName\>
    <label\>Test Two</label\>
    <flowTestDataSources\>
        <apexClass\>FlowTestDataFactory</apexClass\>
        <dataSourceType\>ApexClass</dataSourceType\>
    </flowTestDataSources\>
    <flowTestFlowVersions\>
        <flowVersionNumber\>1</flowVersionNumber\>
    </flowTestFlowVersions\>   
    <isolatedObjectExternalKeys\>
        <keyFields\>
            <fieldName\>Phone</fieldName\>
        </keyFields\>
        <objectType\>Account</objectType\>
    </isolatedObjectExternalKeys\>
    <testPoints\>
        <elementApiName\>Start</elementApiName\>                  
        <parameters\>
            <leftValueReference\>Accounts</leftValueReference\>
            <type\>InputVariable</type\>
            <value\>
                <jsonValue\>{&quot;fields&quot;:{&quot;Phone&quot;:&quot;4155551212&quot;},&quot;attributes&quot;:{&quot;type&quot;:&quot;Account&quot;}}</jsonValue\>
            </value\>
        </parameters\>
    </testPoints\>
    <testPoints\>
        <assertions\>
            <conditions\>
                <leftValueReference\>Accounts.Phone</leftValueReference\>
                <operator\>EqualTo</operator\>
                <rightValue\>
                    <stringValue\>4155551212</stringValue\>
                </rightValue\>
            </conditions\>         
            <errorMessage\>Account not found.</errorMessage\>
        </assertions\>
        <elementApiName\>Finish</elementApiName\>
    </testPoints\>
    <testType\>WithAssertion</testType\>
</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\>66.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](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/file_based_zip_file.htm "The deploy() and retrieve() calls are used to deploy and retrieve a .zip file. Within the .zip file is a project manifest (package.xml) that lists what to retrieve or deploy, and one or more XML components that are organized into folders.").