Industries & compliance

Salesforce Test Automation: Why 75% Code Coverage Isn't Enough (and What to Automate)

Aslam KhanAslam Khan 12 min read
Black and silver laptop computer — Salesforce Automated Testing

The deployment went through without a hitch. Every Apex test passed, org-wide coverage sat at 82%, and the change set landed in production on Friday evening.

On Monday, sales reps couldn't convert leads of one record type. A new validation rule blocked them, and no unit test had ever clicked Convert as a sales rep. That gap between covered code and a working business is what Salesforce test automation has to close.

Salesforce test automation means checking your org's business processes automatically, not just its Apex code. The 75% coverage rule only gets code into production. A good suite also runs lead-to-opportunity, quote-to-cash, cases, approvals and permissions through the Lightning UI and APIs, in a sandbox, before every change and every seasonal release.

Key takeaways

  • 75% Apex coverage is a deployment gate, not a quality bar. It says nothing about flows, validation rules, page layouts or permissions.
  • Automate by business process: lead-to-opportunity, quote-to-cash and CPQ, case management, approvals, and each key profile or permission set.
  • Plan regression around Salesforce's three releases a year. Run the suite in a preview sandbox during the six-week sandbox preview window.
  • Pick tools by layer: Apex and Flow tests for logic, LWC Jest for components, and a UI tool that copes with Lightning's shadow DOM for end-to-end journeys.

Our Salesforce coverage is above 75%. Why do we keep getting production bugs?

Because code coverage measures lines of Apex, and many Salesforce failures don't live in Apex.

Salesforce's own rule is clear. To deploy Apex or package it for AppExchange, unit tests must cover at least 75% of your Apex code and those tests must pass. Every trigger must have some coverage. Salesforce's testing best practices add a telling line: "don't focus on the percentage of code that is covered."

Coverage counts executed lines, not checked outcomes. A test can run most of a class without one meaningful assertion. And much of a modern org is declarative: flows, validation rules, layouts, Lightning pages, permission sets and approval processes. None of that shows up in the coverage number.

What breaks in productionCaught by 75% Apex coverage?What does catch it
Record-triggered flow takes the wrong pathNoFlow tests, end-to-end tests
New validation rule blocks a user journeyNoEnd-to-end test as that user
Lightning page or layout hides a fieldNoUI test
Profile or permission set change removes accessNoTests run as each key persona
Quote calculates the wrong discountOnly if pricing is Apex with real assertionsCPQ end-to-end test
Integration sends bad data to ERP or billingPartly (mocked callouts)API and end-to-end tests in a sandbox
Seasonal release changes component behaviourNoRegression suite in a preview sandbox

Keep the Apex tests. Then add layers that test how people use the org.

What does test automation in Salesforce cover?

LayerWhat it testsTypical toolsUsual owner
Apex unit testsClasses and triggersApex testing frameworkDevelopers
Flow testsRecord-triggered and autolaunched flow logicFlow Builder testsAdmins
LWC component testsLightning web components in isolationJestFront-end developers
UI and end-to-end testsFull user journeys through LightningUI automation toolsQA, admins, business analysts
API and integration testsREST and SOAP calls, connected systemsAPI testing toolsDevelopers, QA

Salesforce testing pyramid: many fast Apex unit tests at the base, fewer LWC component tests in the middle, and a small suite of UI and end-to-end tests at the top.

Push each check as low as it can go. Pricing maths belongs in an Apex test. "A sales rep can take a lead to a closed opportunity" belongs in an end-to-end test, because only that test sees the layout, validation rules, flow and permissions together.

Good Apex tests still matter. Give each trigger a single-record test, a bulk test (say, 200 records, to surface governor-limit problems) and a negative test. Create test data in the test and avoid SeeAllData=true.

What should you automate first in Salesforce?

Start with the processes that cost money or customers when they break.

ProcessWhat the end-to-end test should do
Lead-to-opportunityCreate a lead, qualify it, convert it, check the account, contact and opportunity, then move the opportunity through each stage to Closed Won
Quote-to-cash and CPQConfigure products, apply pricing rules and discounts, generate the quote, approve it, and check totals against an expected result
Case managementCreate cases from each channel, check assignment and escalation rules, entitlements and milestones, then close the case
ApprovalsSubmit a record, approve and reject it as the right approvers, and check the field updates and notifications
Profiles and permission setsRun the key journeys as each persona and check what each one can and can't see or edit

Then add integrations: an order that should reach the ERP, or a web form that should create a lead. Write each test as a business scenario with an expected outcome, not a click script.

How do you test profiles and permission sets?

Run the same journey as different users. Create one test user per key persona (sales rep, manager, service agent, partner user) with production's permission sets, and log in as each.

Check both directions: a rep can edit their own opportunities, and can't see discount approval fields. Permission bugs show up as a missing button or a read-only field, so only a test running as that user catches them. Rerun these tests after every permission set or profile change.

How do you handle Salesforce's three releases a year?

Salesforce delivers new features three times a year in its seasonal releases: Spring, Summer and Winter. Your org is upgraded whether or not you've tested.

The tool for this is the sandbox preview. Salesforce describes it as a six-week window before a major release, when every preview sandbox gets the next release early. For Spring '27, the window begins on 8 January 2027; a sandbox has to be created or refreshed onto a preview instance before 6:00 PM PT on 7 January 2027, and non-preview instances upgrade on 19 and 20 February 2027. Check that article each cycle, because the dates change.

A workable release routine:

  1. Put at least one sandbox on a preview instance before the cut-off, and keep another on the current release to compare.
  2. Run the full regression suite in the preview sandbox once it's upgraded, then weekly until production upgrades.
  3. Read the release notes for the features you use, including release updates that will be enforced.
  4. Sort failures. Locator or layout changes are test maintenance; behaviour changes are real findings.
  5. Run a smoke suite in production right after the upgrade.

Between releases, run the same suite after every sandbox refresh and before every deployment. See automated regression testing for how to size and schedule a suite.

How should you set up sandboxes and test data?

Salesforce offers four sandbox types.

SandboxWhat it copiesBest for
DeveloperProduction metadataBuilding and unit testing
Developer ProProduction metadata, larger data setsDevelopment, QA and integration testing
Partial CopyMetadata plus a sample of data defined by a sandbox templateQA, UAT and integration testing
FullA replica of production, including all data and metadataStaging, performance and load testing

Salesforce notes that the long refresh interval makes Full sandboxes hard to use for development. Run end-to-end regression in a Partial Copy or Full sandbox, and keep Developer sandboxes or scratch orgs for build-time checks.

Test data breaks Salesforce tests as often as code does. A few rules help:

  • Create what you need in the test rather than relying on a record someone might edit.
  • Use unique names (a run ID in the account name) so parallel runs don't collide, and clean up afterwards.
  • Mask personal data in any sandbox copied from production.
  • Re-check after every refresh. A refresh rebuilds the sandbox as a new copy of production, so anything unique to it, such as test users and seeded data, is gone. Script that setup.

More on managing test environments.

Why does Salesforce UI test automation break so often?

Lightning web components use shadow DOM, a standard that encapsulates each component's internal DOM. In Lightning Experience, LWC uses a synthetic shadow polyfill. Many element IDs are also generated at render time, so an ID you record today may be different tomorrow.

That causes three kinds of breakage:

  • XPath and deep CSS paths fail when a component's internal markup changes, which can happen in any release.
  • Shadow boundaries hide elements. Playwright's locators work inside shadow DOM by default, except XPath. Selenium 4 has shadow root methods, but you step into each root yourself.
  • Timing. Components load asynchronously, so a script that clicks too early fails intermittently.

What works, most stable first:

  1. Roles and accessible names, such as the button named Save. Playwright recommends role locators first.
  2. Your own data-id attributes on custom LWC components, as a development standard.
  3. Field API names exposed by standard components.
  4. CSS classes, only as a last resort. Avoid XPath that walks the DOM structure.

Salesforce also maintains UTAM, the UI Test Automation Model: page objects written in JSON and compiled to Java or JavaScript.

Self-healing tools describe each step by intent and adapt when a locator changes; see self-healing test automation for how that works and its limits.

Which automated testing tools for Salesforce should you consider?

Options by category, as of November 2026, described from each vendor's own pages.

Salesforce-native tools

  • Apex tests: the built-in framework for classes and triggers, and the basis of the 75% rule.
  • Flow tests: before you activate a record-triggered, autolaunched or Data Cloud-triggered flow, you can test it in Flow Builder with assertions. Screen flows aren't on that list, so test those through the UI.
  • LWC Jest tests: Salesforce recommends Jest for unit testing Lightning web components. They don't run in a browser or connect to an org, so they're fast but isolated.
  • UTAM: page objects for UI tests; you still need a test runner and coding skills.

Salesforce-specialist platforms

  • Provar: describes itself as a Salesforce partner since 2014 with metadata-driven tests, locators for Visualforce, CPQ, Aura and LWC, and updates in line with Salesforce's three annual releases. Low-code and pro-code options. Pricing on request.
  • Copado Robotic Testing: described by Copado as built for Salesforce and native to Salesforce DevOps, with no-code, low-code and pro-code options and pipeline quality gates. Its QForce keyword library is a Robot Framework testing library for Salesforce, with UI, REST API and CPQ quote keywords. Pricing on request.
  • Tricentis Testim Salesforce: Tricentis says it offers metadata-aware Salesforce steps, uses org metadata to test Flows, and pre-release tests its built-in steps against new releases. It also lists natural-language test creation. Pricing on request.
  • ACCELQ: a codeless, AI-driven platform covering Classic, Lightning and LWC, UI and API, aligned to Salesforce releases, and listed as an ISV partner. Its pricing page shows free and trial tiers; paid plans are pricing on request.

Do-it-yourself frameworks

  • Playwright and Selenium: free and open source. You build and maintain login handling, waits, locators and reporting yourself.

AI-native platforms

  • Robonito: AI agents build, run and maintain end-to-end tests from plain language or a recording (details below).
OptionLayerWho builds testsBest fit
Apex and Flow testsLogicDevelopers, adminsEvery org, as the base layer
LWC Jest, UTAMComponents, UI page objectsDevelopersTeams with heavy custom LWC work
ProvarUI, API, dataQA engineers, low-code usersSalesforce-centred QA teams
Copado Robotic TestingUI, API, in the DevOps pipelineAdmins, QATeams already on Copado
Testim SalesforceUI, FlowsQA, adminsTeams wanting metadata-aware steps
ACCELQUI, APIManual testers, BAsCodeless teams across Salesforce and other apps
Playwright, SeleniumUIDevelopersEngineering-led teams with time to maintain code
RobonitoUI, API, end to endQA, admins, BAsTeams wanting plain-language tests with self-healing

For more on UI tooling, see UI automation testing.

Salesforce test automation with Robonito

Robonito is an agentic QA platform. Its AI agents create, run and maintain end-to-end tests, and Salesforce testing runs through the Lightning UI the way your users work.

  • Plain-language tests. Describe a journey, such as "convert a lead, create a quote and submit it for approval", and the agent works through your sandbox step by step. You can also paste a Jira issue into AI Studio, record a flow in the desktop app, or build no-code tests from reusable steps.
  • Self-healing steps. When a label, layout or locator changes after a release, steps adapt, and every healed step is logged for review.
  • UI and API. Web testing is on every plan. API testing, including Postman collection import, is on Pro and Enterprise.
  • Release and CI runs. Run suites in parallel cloud workers after a sandbox refresh, in the preview window, or from Jenkins, GitHub Actions, GitLab CI, Azure DevOps or CircleCI (Starter and above). Jira, Slack, TestRail and Zephyr integrations are available.
  • Evidence. Every run keeps video, network traces and an AI root cause for failures, with pass rates and trends across runs.
  • Enterprise controls. SOC 2 Type II (report under NDA), RBAC and audit logs, and cloud, private cloud, on-premise or hybrid deployment. See security and compliance.

Club Car cut QA testing time by over 70% with Robonito on its CPQ and website configurator project, built on Logik.io. Read the Club Car case study.

Where it fits. Teams whose admins, business analysts and QA testers need to own end-to-end Salesforce regression without writing Selenium or Playwright code, and orgs that spend each release fixing broken locators. People stay on exploratory testing and UAT.

Where it doesn't fit. Robonito doesn't replace Apex tests, Flow tests or LWC Jest tests; keep those in your Salesforce development workflow, because the 75% rule still applies. It isn't a Salesforce DevOps tool either, so metadata deployment and org-to-org promotion stay with the Salesforce CLI or your release tool. If your team is mostly developers who already maintain a Playwright suite, that may be enough.

See how it runs on your own org: , or .

Frequently asked questions

What is Salesforce test automation?

Salesforce test automation uses software to check that your org still works after every change. It spans Apex unit tests, Flow tests, Lightning web component tests, API tests and end-to-end UI tests. Apex tests are required to deploy; end-to-end tests prove that lead conversion, quoting, cases and permissions still work for real users.

Is 75% code coverage enough for Salesforce?

It's enough to deploy, not to trust a release. Salesforce requires unit tests to cover at least 75% of your Apex code, with every test passing. But coverage counts executed lines, not checked outcomes, and ignores flows, validation rules, layouts and permissions. Add real assertions, Flow tests and end-to-end tests.

How often does Salesforce release updates?

Salesforce ships three seasonal releases a year: Spring, Summer and Winter. Before each comes a six-week sandbox preview window, when preview sandboxes get the new release early. For Spring '27, the window starts on 8 January 2027. Run your full regression suite in a preview sandbox during that window.

Can you use Selenium or Playwright for Salesforce UI test automation?

Yes, but you maintain everything yourself. Lightning web components use shadow DOM. Playwright locators work inside it by default, except XPath, while Selenium 4 needs explicit shadow root calls. Use role-based locators, add data-id attributes to custom components, and avoid structural XPath. Expect locator maintenance after seasonal releases and layout changes.

What are the best automated testing tools for Salesforce?

It depends on the layer and who builds the tests. Use Apex tests, Flow tests and LWC Jest for logic and components. For end-to-end tests, specialist platforms include Provar, Copado Robotic Testing, Testim Salesforce and ACCELQ. Playwright and Selenium suit engineering-led teams; AI-native platforms such as Robonito suit plain-language, self-healing tests.

Do you need a full sandbox for Salesforce regression testing?

Not always. Salesforce reserves performance testing, load testing and staging for Full sandboxes, but many teams run end-to-end regression in a Partial Copy sandbox seeded from a template. Whatever you use, script your test users and data setup, because a refresh rebuilds the sandbox from production and wipes what you created there.


Stop finding Salesforce bugs on Monday morning. to see your lead-to-cash journey tested end to end, or .

Free whitepaperThe Agentic QA PlaybookMove from test scripts to AI agents in 90 days, with the controls, metrics and a 25-question vendor checklist.

No-code AI test automation

Spend less time testing and more time shipping.

3Pillar showed Robonito's agents to its own client live, and that client is now onboarding. Start on the Free plan, which stays free forever, or book a demo and we'll walk through your own app.

Newsletter

Get new posts by email

Practical guides on software testing, QA automation and AI agents. One email when we publish, no spam.

We'll send a confirmation email first. Your details are stored with Mailchimp, our email provider.

All blog posts