Welcome to another “Automate This!” In this live-streamed video series, we cover all things automation, from use cases and best practices to showcasing solutions built by #AwesomeAdmin Trailblazers like you. With automation, you can remove manual tasks, drive efficiency, and eliminate friction and redundancy. In this episode, four community Flow experts showcase a Flow feature you can use in record-triggered flows. This blog post covers the flow testing feature Nadina Lisbon showcased during the episode.
Gone are the days of only being able to debug your record-triggered flows manually. With the Summer ’22 Release, you can now write Automated Tests! Currently, flow tests only support flow paths that run immediately.
Note: This feature is a Beta Service, which means customers may opt to try this feature at your sole discretion. Any use of the Beta Service is subject to the applicable Beta Services Terms provided at Agreements and Terms.
Why do we test?
As we continue to build more and more record-triggered flows, it’s important to ensure that they work as expected. Being able to automate testing will not only save us time but also improve the quality of our record-triggered flows. Previously, we would run the record-triggered flow, then retroactively fix the errors as we debugged. Now, we have more control as we can test our functionality upfront, giving us Flownatics MOAR time to create even MOAR flows!
What are we testing?
Before we dive into our testing, let’s quickly talk about the record-triggered flow we need to test. Below, I have a record-triggered flow that does the following:
Based on the Customer Priority
When the Customer Priority is set to High
Post To Chatter
When the Customer Priority is set to Medium
Change the Rating to Warm
Types of tests and test cases
As we think about our testing outcomes, it’s important to write different test types. We’ll focus on positive and negative tests.
A positive test returns the results we’re expecting. A negative test is used to test how our flow handles invalid or unexpected data. With our given scenario, here are our test cases:
Positive test
When the Customer Priority is set to High
Assertion: A Chatter FeedItem is created
When the Customer Priority is set to Medium
Assertion: Account Rating will equal Warm
Negative test
When the Customer Priority is set to Low
Assertion: Chatter FeedItem is not created
Assertion: Account Rating does not change
Note: We can create 200 tests per a given flow.
Setup
Now that we know what we want to test, let’s get started! To view test run details, you need the View All Data permission. Note: You can view test results and run tests without the View All Data permission.
First, we’ll access the test area by clicking View Test (Beta).
This will bring us to the Tests page where we’ll click Create.
Since this is our first test for the flow, we’ll automatically be directed to the New Test page.
Here’s where the magic begins! Let’s start with our positive test. Specifically, let’s create the test case for when the Customer Priority field is set to High.
Set Attributes as the following:
Label: Customer Priority High
API Name: Account_Create_Customer_Priority_High (This will be automatically generated once the label is filled.)
Description: Test when the Customer Priority is set to High
Given that our flow is only for Create, we’ll leave the Run the Test When a Record Is value as Created.
Next, we’ll set the data for the record in the Set Initial Triggering Record tab. Instead of inputting data, I’ll use the account record called “Burlington Textiles Corp of America” that’s already set up in my org. I’ll change the Customer Priority field to High and click the Set Assertions tab.
Now, we’ll create an assertion to test that we posted to Chatter correctly. To do this, we need to check that a FeedItem record was created properly.
On the Set Assertions tab, we’ll click Save.
Now, let’s run our test.
Hooray! Our test was successful.
Let’s create our last positive test, where the Customer Priorityfield is set to Medium.
Label: Customer Priority Medium
API Name: Account_Create_Customer_Priority_Medium (This will be automatically generated once the label is filled.)
Description: Test when the Customer Priority is set to Medium
Again, we’ll use our Burlington Textiles Corp of America account and change the Customer Priority field to Medium. Next, we’ll click the Set Assertions tab.
For this assertion, we’ll test that our field updated correctly, so we want to check that Account Rating is now Warm.
Finally, we run our test and can see that when the Customer Priority was set to Medium,the Account Rating updated to Warm.
Now, let’s do our negative test.
Label: Customer Priority Low
API Name: Account_Create_Customer_Priority_Low (This will be automatically generated once the label is filled.)
Description: Test when the Customer Priority is set to Low
We set the Customer Priority field to Low and click the Set Assertions tab.
This time, we’ll have two assertions. We want to check that our FeedItem record was not created and that theAccount Rating was not changed. We’re doing this since this is our Default path in the flow, so we’re asserting the default outcome within our decision was performed.
After running our test, we can see it’s behaving as expected.
Let’s recap
And with that, we’ve successfully tested our record-triggered flow! Here are some of the key takeaways from this post:
The maximum number of tests per flow is 200.
Flow tests support only flow paths that run immediately.
To view test run details, you need the View All Data permission.
Welcome to another “Automate This!” In this live-streamed video series, we cover all things automation, from use cases and best practices to showcasing solutions built by Awesome Admin Trailblazers like you. With automation, you can remove manual tasks, drive efficiency, and eliminate friction and redundancy. In this episode, let’s see how Bradley Condon built the […]
Welcome to another “Automate This!” In this live-streamed video series, we cover all things automation, from use cases and best practices to showcasing solutions built by Awesome Admin Trailblazers like you. With automation, you can remove manual tasks, drive efficiency, and eliminate friction and redundancy. In this episode, let’s see how Ohad Idan vanquishes shared […]
Welcome to another “Automate This!” In this live-streamed video series, we cover all things automation, from use cases and best practices to showcasing solutions built by Awesome Admin Trailblazers like you. With automation, you can remove manual tasks, drive efficiency, and eliminate friction and redundancy. In this episode, learn how Becka Dente leverages a simple […]