The deployment validated on Friday at 76% coverage. On Monday a nightly data load failed with "Too many SOQL queries: 101", the UI regression run went red because a Lightning page layout had changed, and two Apex tests failed only when the whole suite ran together. Nobody had shipped a bug. The team still lost the morning.
That is where most Salesforce testing time goes: not finding defects, but rerunning, debugging and repairing tests that fail for reasons unrelated to the change being tested.
To cut Salesforce testing time, stop treating 75% Apex coverage as the goal. Write assertions that check outcomes, make every test bulk-safe and self-contained with a test data factory and @TestSetup, and automate UI journeys with tests that don't depend on brittle Lightning selectors. Then run the suite on every change instead of by hand.
Key takeaways
- 75% coverage is Salesforce's deployment minimum, not a measure of quality. Assertions are what catch regressions.
- Most "passes in sandbox, fails in production" problems are governor limits hit by code that isn't bulk-safe.
- Isolated test data (a factory plus
@TestSetup) removes the failures that only happen in a full run. - The biggest time savings come from automating the journeys people still click through by hand. Club Car cut QA testing time by over 70% with Robonito that way, on its CPQ configurator.
Where does Salesforce testing time actually go?
Look at what happens when a run fails. The time usually lands in four buckets:
- False failures. A test fails, someone investigates, and the cause is test data, run order or a selector, not the code.
- Limit failures that appear late. Code that worked on a handful of records hits a governor limit on a real data load.
- Manual walkthroughs. Flows, approvals, quotes and configurators that nobody has automated get clicked through before every release.
- Repairs after UI changes. Browser tests break when a page layout, a component or a Salesforce release changes the page.
More tests fix none of these. Better test design, and running tests on every change, fix all four.
What does the 75% Apex coverage rule actually require?
Salesforce's rule is precise. To deploy Apex to production or package it for AppExchange, unit tests must cover at least 75% of your Apex code, those tests must pass, and every trigger must have some coverage (Salesforce Apex Developer Guide: Testing and Code Coverage).
How the 75% is measured depends on the test level you deploy with:
| Test level | What runs | How coverage is checked |
|---|---|---|
RunLocalTests (default for production deploys with Apex) | All local tests in the org | Overall coverage must be at least 75% |
RunSpecifiedTests | Only the tests you name | Each class and trigger in the package needs 75% on its own |
Source: Salesforce CLI reference: project deploy start.
With RunLocalTests, a well-tested org can carry a new class with almost no tests and still deploy, because the average hides it. With RunSpecifiedTests, that same class blocks the deployment. Either way, ship each test class with the code it tests.
Why doesn't more coverage mean better quality?
Coverage tells you which lines ran, not whether the result was right. A test can execute every line of a discount calculation and pass with the wrong discount, as long as it never checks the number.
// Passes the coverage gate, proves almost nothing
System.assertNotEquals(null, quote);
// Checks the behaviour the business depends on
System.assertEquals(0.10, quote.Discount__c, 'Gold accounts get a 10% discount');
Salesforce's own guidance points the same way: cover every use case, including positive and negative cases, bulk and single records (Salesforce Apex Developer Guide: Testing Best Practices).
In practice, that means three habits:
- Assert on specific values: field updates, record counts, statuses and error messages.
- Add a negative test for each validation rule.
- Add a bulk test for every trigger, because triggers rarely run on one record in production.
Fewer tests with real assertions take less time to run and investigate, and they fail for reasons that matter.
Why do Apex tests pass in a sandbox and fail in production?
Usually because of data volume. Salesforce's sandbox types copy very different amounts of data (Salesforce Help: Sandbox Types and Templates):
| Sandbox type | What it copies |
|---|---|
| Developer and Developer Pro | Metadata only, no production data |
| Partial Copy | Metadata plus a sample of production data, defined by a sandbox template |
| Full | A replica of production, including all data |
Code tested on a handful of records never meets production volumes until it hits the governor limits. In a synchronous transaction, Apex can issue 100 SOQL queries and 150 DML statements, and asynchronous Apex gets 200 queries (Salesforce Apex Developer Guide: Execution Governors and Limits). The 101st query throws the "Too many SOQL queries: 101" error, and a governor limit exception can't be caught.
The classic cause is a query inside a loop. Triggers process records in batches of up to 200, so a query per record breaks as soon as a real data load arrives (Salesforce Apex Developer Guide: Triggers).
// Before: one query per record. Fails on a 200-record batch.
for (Opportunity opp : Trigger.new) {
Account acc = [SELECT Id, Industry FROM Account WHERE Id = :opp.AccountId];
// ...
}
// After: one query for the whole batch, results kept in a Map
Set<Id> accountIds = new Set<Id>();
for (Opportunity opp : Trigger.new) {
accountIds.add(opp.AccountId);
}
Map<Id, Account> accounts = new Map<Id, Account>(
[SELECT Id, Industry FROM Account WHERE Id IN :accountIds]
);
for (Opportunity opp : Trigger.new) {
Account acc = accounts.get(opp.AccountId);
// ...
}
To catch this early, write bulk tests that insert 200 records, and run the full suite in a Partial Copy or Full sandbox before major releases.
How do you make Apex tests bulk-safe and isolated?
Flaky Apex tests are almost always data problems. Since API version 24.0, test methods can't see existing org data by default, only the records they create (Salesforce Apex Developer Guide: Using the isTest(SeeAllData=True) Annotation). Keep it that way, and build data through one place.
@isTest
private class OpportunityServiceTest {
@TestSetup
static void setup() {
insert TestDataFactory.createAccount('Acme Corp');
}
@isTest
static void createsTwoHundredOpportunitiesInOneTransaction() {
Account acc = [SELECT Id FROM Account WHERE Name = 'Acme Corp' LIMIT 1];
List<Opportunity> opps = TestDataFactory.createOpportunities(acc.Id, 200);
Test.startTest();
insert opps;
Test.stopTest();
System.assertEquals(200, [SELECT COUNT() FROM Opportunity WHERE AccountId = :acc.Id]);
// Then assert the fields your trigger should have set, not just the count.
}
}
Three platform behaviours make this pattern work:
@TestSetupgives every method the same starting data. Records are created once per class, and any changes a test method makes to them are rolled back when it finishes, so the next method sees the originals. A class can have one test setup method (Salesforce Apex Developer Guide: Using Test Setup Methods).Test.startTest()andTest.stopTest()separate setup from the code under test. Code between them gets a fresh set of governor limits, and async work queued inside the block (@future, batch jobs) runs synchronously atstopTest(), so you can assert on it straight after (Salesforce Apex Developer Guide: Using Limits, startTest and stopTest).- A
TestDataFactorykeeps required fields in one place. When an admin adds a required field, you update one class, not every test.
What about UNABLE_TO_LOCK_ROW in parallel test runs?
Lock errors and deadlocks appear when parallel tests update the same records at once, usually because tests use SeeAllData=true and share org data (Salesforce Apex Developer Guide: Testing Best Practices).
The real fix is for each test to create its own data. If you need a stopgap, Salesforce offers an org-wide Disable Parallel Apex Testing option under Apex Test Execution options (Salesforce Help: Disable Parallel Test Execution). Note that @isTest(IsParallel=true) does the opposite of what many expect: it forces a class to run in parallel even when that option is on (IsTest Annotation).
Why do Salesforce UI tests break so often?
Apex tests can't tell you whether a rep can still create a quote or whether an approval still reaches the right person. Those UI journeys are where manual walkthroughs eat the most time, and browser tests for them are fragile. Salesforce's own documentation for its UI Test Automation Model (UTAM) says the DOM of its apps changes from release to release, and that tests built on query selectors break when the DOM structure changes (Salesforce Developers: What is UTAM?). Lightning components also render inside shadow DOM, which ordinary CSS selectors can't cross (UTAM tutorial: Web Components and Shadow DOM). Add Salesforce's seasonal Spring, Summer and Winter releases (Salesforce release notes index) and the admins' weekly layout changes, and selector-based suites need constant repair.
There are two sound ways to cut that repair work:
- Page objects. UTAM gives you JSON page objects, and Salesforce plans to ship page objects with each release. You still maintain them for custom components, and you need engineers to write the tests.
- Self-healing, intent-based tests. Tools that describe a step by what it does ("click Save on the Opportunity") rather than by a CSS path can adapt when the page changes. See how self-healing test automation works for the trade-offs.
Start with the journeys where a failure costs money, such as quote to order. For a wider look at tools and approaches, read our Salesforce automated testing guide.
What did Club Car's over 70% cut actually come from?
Club Car builds golf cars and personal transportation vehicles. Its website configurator, where customers build and price a vehicle, sits on a CPQ (configure, price, quote) project built on Logik.io. With Robonito, Club Car cut QA testing time by over 70% (Club Car case study).
A note on Logik.io. It is listed on Salesforce AppExchange as a configurator that, in the listing's words, "supercharges Salesforce CPQ & Commerce Cloud" (AppExchange: Logik.io, Configurator for CPQ & Commerce). It isn't a Salesforce company: ServiceNow announced its acquisition of Logik.ai in April 2025 (ServiceNow newsroom). The case study doesn't say which CRM sits behind Club Car's configurator, so treat the result as a CPQ configurator result, not a measurement of a Salesforce org.
What the case study does say:
- Club Car used Robonito Enterprise with test-writing support. The team demonstrated the test cases it wanted, and Robonito's team recorded and built them.
- Hundreds of tests were recorded and run straight away, with no training on a new tool.
- Logik.io configurations and the CPQ configurator are now tested automatically instead of by hand.
The lesson carries over to any Salesforce team with CPQ or complex flows. The time came back from replacing manual walkthroughs of option rules and pricing with automated runs on every change, not from chasing coverage.
Where does Robonito fit in Salesforce testing?
Robonito is an agentic QA platform: AI agents create, run and maintain end-to-end tests. For Salesforce, it covers the UI journeys your users actually take (Salesforce QA automation).
- Plain-language or recorded tests. Describe what to test in AI Studio, paste a URL or reference a Jira issue, and the agent works through the app step by step. Or record a flow in the desktop app.
- Self-healing steps. When labels, layouts or locators change, steps adapt, and healed steps are logged so you can review them.
- Runs on every change. Tests run in parallel in isolated cloud workers, or from CI/CD with Jenkins, GitHub Actions, GitLab CI, Azure DevOps or CircleCI (Starter plan and above). Every run keeps video, network traces and an AI root cause for failures.
- Help writing tests. On enterprise engagements, Robonito's professional services team can write tests for you, as it did for Club Car.
Where it doesn't fit. Robonito doesn't replace Apex unit tests, and it doesn't count towards the 75% deployment coverage. You still need bulk-safe, isolated Apex tests. Robonito covers the journeys Apex can't see.
Web testing is on every plan, including the free plan with 100 test cases (pricing). to see a Salesforce journey run end to end, or .
Salesforce testing checklist
Apex tests
- Ship every Apex class and trigger with its test class in the same deployment.
- Assert on specific values, not
nullchecks. Add a negative test for each validation rule. - Add a 200-record bulk test for every trigger.
- Search for SOQL and DML inside
forandwhileloops, and move them out using aMap. - Build all test data through a
TestDataFactoryand@TestSetup. AvoidSeeAllData=true.
UI journeys
- List the journeys still tested by hand and rank them by what a failure costs.
- Automate the top journeys first: quote, order, approval, case.
- Use page objects or self-healing tests instead of raw CSS selectors.
Pipeline and releases
- Run
sf apex run test --code-coverage --test-level RunLocalTestsin CI and review per-class coverage, not only the org average (Salesforce CLI: apex run test). - Before each Salesforce seasonal release, run the full suite in a sandbox on the new release.
- Track false failures per run. If they rise, fix the test design before adding tests.
Frequently asked questions
Does Salesforce require 75% test coverage?
Yes. To deploy Apex to production, unit tests must cover at least 75% of your Apex code, all those tests must pass, and every trigger needs some coverage. With RunSpecifiedTests, each class and trigger in the deployment needs 75% on its own.
Why do Apex tests pass in a sandbox but fail in production?
Usually governor limits. With only a few test records, a SOQL query inside a loop stays under the 100-query limit; a 200-record batch in production breaks it. Bulk tests and bulk-safe code prevent this.
How do you reduce Salesforce testing time?
Fix false failures first: isolate test data, remove queries from loops and replace brittle selectors. Then automate the journeys still tested by hand. Club Car cut QA testing time by over 70% with Robonito by automating its CPQ configurator testing.
How do you fix UNABLE_TO_LOCK_ROW errors in Apex tests?
Make each test create its own data instead of sharing org records through SeeAllData=true. As a stopgap, you can turn on Disable Parallel Apex Testing in Apex Test Execution options. @isTest(IsParallel=true) forces a class to run in parallel; it doesn't stop it.
Can you automate Salesforce testing without code?
For UI journeys, yes. No-code and AI-based tools test Lightning pages and flows through the browser. Apex unit tests still need code, because only they count towards the 75% requirement.
Stop clicking through the same quote and approval flows every release. to see your Salesforce journeys run end to end, or .




