Loading
Connect in real time with the Trailblazer Community in Slack Open BetaRead More
Automate Your Business Processes with Salesforce Flow
Automated Flow Testing

Automated Flow Testing

Understand assertions, flow versions, and test data before you set up an automated test scenario through Test Mode or for a Data Cloud-triggered flow.

Required Editions

View supported editions.
User Permissions Needed
To open, edit, create, activate or deactivate a flow using all flow types, elements, and features available in Flow Builder, including Einstein and Agentforce for Flow: Manage Flow
To view test run details in Flow Builder: View All Data

Why Automate Testing

Automated testing saves you time and improves your flow's reliability. Configure a test scenario once, and each automated run reuses the same inputs and assertions. You're not limited to one test scenario per flow. Create as many test scenarios as you want to cover different paths and conditions.

Automated test scenarios are especially valuable when you deploy a flow from sandbox to production. Use isolated test data so that your test scenarios aren't tied to records in a specific org and run consistently across environments.

We recommend creating a test scenario for every path that the flow can take.

For autolaunched and record-triggered flows, automated testing is one capability in Test Mode. Turn on Scenario Testing Automation when you configure a test scenario. See Testing Your Flow in Test Mode. For Data Cloud-triggered flows, see Test a Data Cloud-Triggered Flow

How Assertions Work

An assertion checks that a resource's value matches what you expect, using an operator such as Equals. After the test scenario runs, each assertion evaluates to pass or fail, based on whether the actual value matches the condition you set. A test scenario passes only when all its assertions pass.

Interpreting Test Results

After a test scenario runs, each assertion shows its status along with two values: the condition, which is the expression you configured, and the condition evaluation, which is the actual runtime value. Expand an assertion to see both values.

When an assertion fails, compare its condition and condition evaluation to find the mismatch. Fix the responsible element in the flow, and then rerun the test scenario to confirm the fix.

Learn more in Interpret Test Scenario Results in Test Mode or Interpret Data Cloud-Triggered Flow Test Results.

Selecting Flow Versions to Test

You can choose which flow version or versions a test scenario runs against. The default selection differs depending on where you configure the test scenario.

For a Data Cloud-triggered flow, a test scenario runs against the flow's active version by default, or its latest version if no version is active.

In Test Mode, a test scenario selects all flow versions by default. Remove versions until only the ones you want to test remain, including down to a single version. For example, if you add new logic to a later version, run the test scenario only against the versions that include that logic.

How Test Runs Affect Your Data

Rollback behavior depends on the testing experience and the scenario configuration. In Test Mode, rollback is on by default. It's required for scenarios with assertions and for record-triggered scenarios where you evaluate expected results manually. A Data Cloud-triggered flow test creates a temporary copy of the triggering record, and the copy isn't saved to the database.

Only Test Mode supports isolated test data. For record-triggered and autolaunched flows, you can use an Apex class with a @testSetup method to create dedicated test records in a data silo.

IN THIS SECTION:

 
Loading
Salesforce Help | Article