Tests for Salesforce Flow

How do you unit test Salesforce Flows? Now you can create, save, and run flow tests in Flow Builder. Each time you modify the flow, you can run the test and assert the result. This Conceptually Similar to Apex Test Classes. Let see how you can test your Salesforce flow using Flow Tests.

What is Flow Tests?

Flow Tests is a Declarative Framework to Test Salesforce Flows. You can create Flow Tests declaratively, execute with the click of a button. It was beta released in Summer ‘22, GA from Winter ‘23.

Tests for Salesforce Flow

Flow Tests is similar to Apex Test Classes. But does not require development / coding skills.

Steps to Create Flow Tests

  1. Set Test Details, Trigger, and Path,
  2. Set Initial Triggering Record,
  3. Set Assertions 

Learn more here.

What is Assertion in flow?

Assertion in tests refers to the validating that the outcome is as expected. For example.

  • Flow should set the Discount % to 10 for Gold Tier Customers with Opportunity Amount < 100,000
  • In Flow Test, we will set assertion to confirm that when an Opportunity is created for Gold Customer the Discount % is set to 10

create & Run Tests for Salesforce Flows Video

How to create & Run Tests for Salesforce Flows Declaratively. Unit test for Flow.

YouTube video

Check Ashish Agarwal Step by Step Guide to Automate Testing of Salesforce Flows Declaratively guide.

Benefits, Limitations & Observations

Why You Should Consider Flow Tests?

  • Makes Flows Robust & Reliable
  • Reduces the Testing Effort by Users
  • ROI multiples with every testing iteration

Limitations on Flow Tests

Here are some limitation of Flow tests.

  1. Limit: The maximum number of tests per flow is 200
  2. Record Triggered Flow Only: Available only for record-triggered flows.
  3. No Support for Delete: Flow tests don’t support flows that run when a record is deleted.
  4. Positive Testing only: It only support positive testing.
  5. Test coverage: Flow tests don’t count towards flow test coverage requirements.
  6. Flow Versions: It independent of flow versions. Saving flow as New Flow will not copy Flow tests.


Deployment of Flow Tests

FlowTest available as separate metadata component for deployment. FlowTest need s to be deployed separately than flows. This will not run automatically on deployment. It supports by Change Set & Packages. You can use Salesforce CLI (SFDX Commands) to retrieve & Deploy.

sfdx force:source:retrieve -m "FlowTest"
sfdx force:source:deploy -m "FlowTest"


Salesforce flow is becoming mature day by day. Unit testing for flows should be added a Best practices for Salesforce Flows.

Amit Chaudhary
Amit Chaudhary

Amit Chaudhary is Salesforce Application & System Architect and working on Salesforce Platform since 2010. He is Salesforce MVP since 2017 and have 17 Salesforce Certificates.

He is a active blogger and founder of Apex Hours.

Articles: 466

Leave a Reply

Your email address will not be published. Required fields are marked *