You have started using Flows for all automation in Salesforce. Great. Your Flow can be anywhere from being quite simple with just one or two elements to very complex with hundreds of elements & decisions criteria.
Flows is arguably one of the most powerful features of Salesforce today. And though it is a cliché but with great power comes great responsibility. Changes to your Flow cannot and should not break any of the existing functionality.
So how are you testing your Flows, especially when you enhance or modify it. How do you ensure that your changes will not break any existing functionality? How do you perform regression tests?
Asking your users to manually test the flow every time you change it will take a lot of time and effort. It may not be exhaustive, and it may not be reliable.
With the Summer ’22 release Salesforce introduced a testing framework for record-triggered Flows to automate the testing of Flows. Now you can let Salesforce test the Flow, ensure that the results are as per the expectation and highlight when they are not. You can now create & run tests within the Flow builder itself – declaratively without writing any code.
If you are familiar with Apex test classes, the concept of testing the flows is similar. It is like writing the test classes for flow that will give you better test coverage.
Here is an exhaustive guide on how to create and run tests for Flows. And this is what we will be covering in this guide:
- Create a Record-Triggered Flow
- Create Test for Flow
- Run Test
- Create Multiple Tests
- Run All Tests
- How Flow Tests Help?
- Create Test from Debug Run
- Considerations for Flow Tests
Learn how to do all this in just under 30-40 minutes. This can save significant time and effort of your users and increase the reliability of your Flows.
NOTE: Certain sections of the guide will appear as locked in the free preview. You can download the unlocked version of the guide in PDF format by subscribing to our “All Access” Pass through the link below.
Introducing Mastering Salesforce Flows Training Course
Liked this post? We are now offering a complete self-paced, video-based training course on Mastering Salesforce Flows. The course comes with downloadable step-by-step PDF guides, unlimited access, free upgrades, community discussion area, free preview and more. For more details, please click here.
Need Help with Flows?
Need advice on Flows? I also offer advisory & consulting services on Salesforce Flows. So, whether you want to create new Flows or migrate existing automations (Workflow Rules, Process Builder, Triggers) to Flows, I can help you analyze, design, plan & review. To initiate a discussion, please submit the contact form here stating your requirement or schedule a discussion at this URL.
References & Useful URLs
- Salesforce Summer 22 Release Note Article – Test One, Two, Three, Flow (Beta)
This looks like only helpful to test in the same sandbox where we develop the flow. Because all the lookups field which are needed for testing will not be available in other sandbox. I tried deploying the tests to different sandbox and everything failed because the lookup id’s are not present in other sandbox.
That is absolutely right Swaroop. This was my observation too. I think since Flow tests have just been introduced, it will take a couple of releases for the feature to mature.
Thanks for this Info. I’ve a question. do we need to write test class for Schedule – triggered flow ? Is that mandatory to deploy a flow to production ? If so can you please post any examples. Thanks in advance!
Hi Swasti, no you don’t need to write any test class for any of the Flows. Flows can be deployed as-is. Unlike Apex, there is no minimum coverage requirement.
very handy guide!
Thanks!
My pleasure Tarun