With the Summer’22 Salesforce release, salesforce introduced View Testing (Beta) to help you test your record-triggered flows. Everyone in the Salesforce ecosystem knows Flow is the future of declarative automation tools. It has started replacing the existing Workflow & Process Builder. After saving the flow triggered by the recording, then the user can click the View Tests (Beta) button to create a new test.
Create, save, and run flow tests in Flow Builder. In the past, you would manually debug your flow and fix any errors as they occurred. Now create and save a flow test from the debug run. Then you can run the test every time you change the flow. Only flow paths that run immediately can be tested. Flow tests do not support flows that run when a record is deleted.
Benefits of Code-less Flow Testing:
- Automates the process of determining whether your flows are performing as expected
- Saves your time and increases the reliability of your flows.
- In flow testing, user configures test parameters and inputs once then same configuration is used to evaluate the flow each time the test is run.
- User can edit the test or create more tests for different scenarios.
Steps to Automate the Flow Testing:
1. On the Flow Builder Screen, click on View Tests (Beta) button present on the right corner of the screen.
2. For a newly created Flow, On the First Pop-up screen click on Create button to start creating test cases.
3. In next step, you need to set the test details such as label, API name and description, DML operation (create or update) and set the path of the test (currently there is a Run Immediately option).
4. It’s time to create the test data, Click on Set Initial Triggering Record on the left side of the screen and set the test data in the form of record and flow will pick the given data for testing.
5. Finally, we need to Set Assertions. Here you can set multiple conditions without limit and set a custom error message for each condition.
Set conditions and custom error messages for each assertion to test your flow. At runtime, the test checks all assertions. An assertion passes if all conditions in each assertion are true. Assertions and test execution fail if the assertion’s condition evaluates false. If an assertion fails during test execution, a custom error message is displayed in the test execution details.
6. Once All assertions are in place, save the test window. User will be directed back to flow builder. Click on View Test (Beta) again and if multiple tests are there select the check box on the right side and click on Run button on the right bottom of the screen.
To Run single test or to view, edit or delete test data click on the left side down arrow and select the desired action.
Beta Limitations and Considerations:
- Tests per flow are limited to 200.
- View Tests (Beta) only support record-triggered flows and flow paths that run immediately.
- Beta Testing does not support packaging and changesets.
- The owner of the flow test trigger record will be the last user to edit the test.
Automated flow testing automates the process of determining whether your flows are performing as expected, saving you time, and increasing the reliability of your flows. When debugging a flow, manually configure debug parameters and inputs each time you start debugging. In flow testing, he configures test parameters and inputs once. The same configuration is used to evaluate the flow each time the test is run. By the way, don’t stick to the same tests for each flow. You can edit tests or create more tests for different scenarios. We recommend creating a test for each path your flow can take.
Leave A Comment