Salesforce is the largest Customer Relationship Management (CRM) tool in the world. Over the years, it has evolved into a beast that can do everything your Sales & Marketing teams need it to do (and more!). Its size means it’s a great addition to your company but also makes it tricky to test.
In this article, we will give you some actionable Salesforce functional testing tips. We hope to make your life testing different functional aspects of Salesforce as painless as possible from day one.
Salesforce Functional Testing Tips
#1 – Run Tests as Real Users
Salesforce tests run at the System level by default. Since your end users will be using Salesforce with user-level permissions, you need to run your tests with these permissions. If you don’t, your tests will likely break and cause unforeseen bugs—things that work in the test environment but not in production. Don’t make this common mistake!
#2 – Create Test User Accounts
You could use real user accounts to run your tests with user-level permissions. Using existing accounts saves the hassle of setting up a new one for you. But this will cause problems if you and the actual user are logged in simultaneously. Salesforce gets confused if it sees one account performing standard Salesforce work and also running functional tests. This confusion will cause all your tests to crash, and your error reports won’t tell you why. This tip alone will save you hours of head-scratching and reduce the number of false positives you see.
#3 – Find the Built-In Features
Salesforce is massive and comes with many built-in features you cannot remove or turn off (even if your company never uses them). If you tested all these built-in features, you would waste a lot of time (since Salesforce has already extensively tested them!). Keep a list of the built-in features so you can just focus on the custom features your business has implemented.
#4 – Test Different Browsers
Salesforce is a web application, and users will interact with it through different browsers. Therefore, you need to perform salesforce functional testing in all browsers. What works in Google Chrome may not work in Safari, which may not work in Firefox, and so on. Checking all the browsers ensures everyone can use Salesforce regardless of their browser preferences.
#5 – Be Aware of Visual Force Pages
Pay extra attention when testing the Salesforce UI. Most of the web pages are Visual Force pages, so not all elements will load simultaneously. Give your test suite enough time to load everything; don’t rush through and assume it is all working since you may be testing aspects that haven’t appeared yet!
#6 – Make Tests Call Multiple Objects
If your tests only call one object at a time, they won’t reflect real-life. To solve this, for each trigger, have at least one test that calls multiple objects. However, Salesforce gives you a limited amount of compute resources for your tests; you don’t want to use them up calling one trigger with too many objects. A good number is 10-20.
#7 – Limit Data Access for Unit Tests
If your functional tests have access to every piece of data your business stores on Salesforce, this won’t reflect your production environment. Limit the amount of data your unit tests have access to by setting seeAllData to false in your test classes. Thankfully, Salesforce recently made this the default behavior for all tests, but it is still good practice to set it manually as it improves code readability.
#8 – Arrange – Act – Assert
Having a framework to follow will significantly improve your efficiency when writing tests and ensure consistent and high-quality output for the long term. First, arrange everything you need for your test—create objects, give appropriate names and prepare your test data. Put this all in a separate method to enhance code readability. Then act—run the logic or business rules you need to test on the objects you arranged. Finally, make sure you assert the results of your tests and check the result. A test that doesn’t assert the result isn’t really a test.
#9 – Automate Your Functional Salesforce Tests
Writing and maintaining all your tests by hand slows you down and makes your tests error-prone. Using testing tools fixes this problem. One such salesforce functional testing tool is Functionize. They use AI-powered low-code automation to make it easy for all teams across your business to implement lightning-fast testing with their end-to-end automation suite. In fact, Salesforce themselves uses it to test their own product! If you’re using Salesforce for your CRM, using the test suite they prefer makes sense.
So there you have it, nine actionable tips to improve your functional testing in Salesforce. But tips are no good unless you implement them. So get out there and start taking action. Every suggestion you implement will improve your company’s Salesforce workflow, which will only enhance your sales and marketing pipeline and lead to more growth for your business.