Iโm going to start this series about Unit Testing with a confession: Iโm not actually a Salesforce admin. Please keep reading! Iโm actually a developer who attends and speaks at admin groups and works alongside a crack team of admins every day.
Our Success team are a smart bunch with a lot of experience and certifications between them. These posts and the talk which spawned them arose because we wanted to introduce them to subjects that are not on the admin learning track, but that we thought might be interesting and help with the work they do for our Support clients.
Support is a big part of our business, and weโve inherited responsibility for a number of Salesforce orgs. Some of them arrived in tip-top condition. Others, older and with significant customisation, were less stable than we would like. They required significant developer time to repair broken Unit Tests, and issues highlighted by broken Unit Tests before any new work could commence.
In this series, Iโll talk (briefly) about what Unit Tests are, why we have them on the Salesforce platform, how to run them and what it can mean when they go wrong, but letโs get one key question out of the way first:
A totally valid question. As a Salesforce admin youโre already swamped with stuff to learn about: three releases a year, constant new features and acquisitions (Mulesoft? Tableau? Einstein? FSL?), not to mention all the community meetups and those blogs, feeds and podcasts that weโre supposed to keep up with; why learn about dev stuff as well? Well, because (drumroll pleaseโฆ)
Itโs not just a hassle for the unlucky developer who gets to fix them, possibly years after they were written, and after anyone can remember why they exist at all (can you feel the anxiety? Yes, Iโve had to do this a lotโฆ). Here are a few reasons why:
Look familiar?
Ok, so I know that you can deploy configuration changes without running your Unit Tests, but itโs time to think about whether you should. My argument is that we should be running our tests more often, and especially when deploying new features.
This is crucial: fixing broken Unit Tests will not fix the problems that they highlight in your org, any more than fixing a broken fire alarm will put out a fire in your house. Unit Tests are designed to fail if the functionality they are testing no longer produces the expected results, and itโs up to us to find out why.
As weโll see later on, some test failures can be repaired by adjusting them to anticipate a small change in configuration. Others, however, have much more complex causes that require investigating changes to platform features, governor limits, managed packages and what may appear to be completely unrelated functionality. This can take a while, and leads me to this:
Everybody in our ecosystem is necessary and valuable, but Salesforce developers are not easy to come by (as youโll know if youโve ever tried to recruit them). Not only that, but our time tends to be block booked for specific projects many weeks or even months ahead. Taking a developer away from their scheduled work to fix Unit Tests can be awkward, which suggests that the ability to identify, and perhaps triage, errors with testing is a very good skill for an admin to have.
Thanks for making it this far! That got the โwhyโ out of the way, so next time Iโll move on to what Unit Tests actually are, how you can run them, and how they can go wrong…
Our independent tech team has been servicing enterprise clients for over 15 years from our HQ in Bristol, UK. Let’s see how we can work together and get the most out of your Salesforce implementation.