Salesforce

Flows, Apex and Triggers: Where Salesforce Logic Lives

Rishabh Kumar

Published On

Salesforce Testing Layers
eBook CTA Background
RECOMMENDED RESOURCES

Salesforce testing: Complex Element Selection Best Practice

While some applications are easy to automate, others, like Salesforce, need a little extra love and attention. This is our best practice guide to complex element selection.

Get the eBook →

Ebook image
eBook CTA Background
RECOMMENDED RESOURCES

Salesforce testing: Complex Element Selection Best Practice

While some applications are easy to automate, others, like Salesforce, need a little extra love and attention. This is our best practice guide to complex element selection.

Get the eBook →

Ebook image
eBook CTA Background
RECOMMENDED RESOURCES
Ebook image

Salesforce testing: Complex Element Selection Best Practice

While some applications are easy to automate, others, like Salesforce, need a little extra love and attention. This is our best practice guide to complex element selection.

Get the eBook →

eBook CTA Background
RECOMMENDED RESOURCES

Salesforce testing: Complex Element Selection Best Practice

While some applications are easy to automate, others, like Salesforce, need a little extra love and attention. This is our best practice guide to complex element selection.

Get the eBook →

Ebook image

Table of contents

Lorem ipsum

Lorem ipsum

Lorem ipsum

Lorem ipsum

Lorem ipsum

A Salesforce release can pass every Apex test, every Flow Test and every agent test, and still break the quote-to-cash process on Monday morning.

Each layer did its job. None of them was asked whether the business still works. Knowing what each layer proves, and what it misses, is how you make sure something answers that question.



What Does Each Salesforce Testing Layer Prove?

Each Salesforce testing layer proves something different. Apex tests prove code logic and meet the 75% coverage rule for deployment. Jest proves Lightning Web Components in isolation. Flow Tests prove record-triggered flow logic. Agentforce Testing Center proves agent reasoning. Integration tests prove systems exchange data correctly. End-to-end UI tests prove a real user can complete a real business journey across all of it.

The lower layers are fast, cheap and precise, but they test parts. Only the top layer tests the whole, and only the top layer answers the question a release owner signs off: does the business still work after this change?



Where Business Logic Lives in a Salesforce Org

In a modern Salesforce org, most business logic lives in configuration rather than code. Flows, validation rules, approval processes and assignment rules sit alongside Apex classes and triggers. That matters for testing, because only the Apex portion is covered by the platform’s coverage requirement.

Where Logic Lives

Examples

Natural Test Layer

Record-triggered flows

Field updates, related record creation, notifications

Flow Tests for immediate paths, end-to-end for side effects

Screen and other flows

Guided processes, scheduled jobs, autolaunched actions

Apex tests or end-to-end journeys

Apex classes and triggers

Complex calculations, integrations, bulk processing

Apex unit tests

Validation rules

Data quality gates on save

End-to-end journeys as real users

Approval processes

Discount, contract and expense approvals

End-to-end journeys as each approver

Assignment and escalation rules

Lead and case routing, SLA escalation

End-to-end journeys with known data

OmniStudio components

Guided intake in Industries orgs

End-to-end journeys

Agent actions

Flows and Apex called by Agentforce

Unit tests plus end-to-end agent journeys



The Salesforce Testing Layers, and What Each One Misses

Layer

What It Proves

What It Misses

Typical Owner

Static analysis (such as Salesforce Code Analyzer)

Code and metadata follow rules for security, performance and style

Whether anything actually works

Developers

Apex unit tests

Classes and triggers behave as written, in bulk and as different users, and code can deploy

The user interface, real data, connected systems

Developers

Jest tests for LWC

A component renders and handles events correctly, with dependencies mocked

How it behaves on a real Lightning page after a release

Developers

Flow Tests

Record-triggered flow logic on its immediate paths

Screen flows, async paths, interaction with other automation

Admins

Agentforce Testing Center

An agent chooses the right topic and actions and responds well

Whether the business outcome of the agent’s actions is correct

Agent builders

API and integration tests

Salesforce and other systems exchange the right data

What the user sees and does

Integration teams

End-to-end journey tests

A real user, with real permissions, completes a real process across Salesforce and connected systems

Fine-grained logic that’s cheaper to prove lower down

QA and release owners

User acceptance testing

The business agrees the change does what it asked for

Repeatability, as it’s usually manual and done once

Business users

Production monitoring

Real usage is healthy after go-live

Anything before go-live

Operations

Notice the pattern in the third column. Every layer below end-to-end misses the same thing in a different way, the process as the business runs it. That isn’t a flaw in those layers. It’s the job of the top one.



One Change, Followed Through Every Layer

Worked example (illustrative)

Today, any discount above 10% needs a manager’s approval. The business decides to raise that threshold to 15%.

Making the change touches three parts of the org. A flow decides when a quote needs approval. An Apex class calculates the quote total. And an approval process sends the quote to the right manager.

Here’s what each test layer checks, and what it would miss on its own.

Layer

What It Checks

What It Would Miss Alone

Apex tests

Quote totals calculate correctly at 14%, 15% and 16%

That the approval process still routes to the right manager

Flow Tests

The flow sets the approval flag above 15%

That a sales rep can still submit the quote from the page

Integration tests

The approved quote reaches the ERP with the right total

That the manager sees the approval request at all

End-to-end journey

A sales rep creates a quote at 16%, it routes to their manager, the manager approves, and the order reaches the ERP

Nothing in the process, but slower to diagnose a calculation bug than an Apex test

Each layer catches something. Only the end-to-end journey proves the changed process works for the people who use it, and only the lower layers pinpoint a calculation error quickly. You need both.



Is 75% Apex Code Coverage Enough?

Salesforce requires unit tests to cover at least 75% of your Apex code, with every test passing and every trigger having some coverage, before code can be deployed to production. It’s a sensible floor, and the most misunderstood number in Salesforce.

Coverage measures which lines ran during a test, not whether the test checked anything. A test that calls a method and asserts nothing still counts. Teams under deployment pressure learn this quickly, and coverage can rise while confidence falls. Salesforce’s own Apex guidance says as much. Don’t focus on the percentage. Focus on covering every use case, positive and negative, single record and bulk.

There’s a second, less obvious point. Salesforce runs the Apex tests in customer orgs to check that platform upgrades haven’t changed behaviour. That’s a real safety net, but it only catches what your Apex tests assert.

Declarative configuration, screen flows, page layouts, permission sets and connected systems sit outside it entirely, and in most modern orgs that’s where most business logic now lives.

What a Good Apex Test Does

Practice

Why It Matters

Uses the Assert class to prove behaviour

A test that asserts nothing still counts towards coverage

Calls methods with valid and invalid inputs

Proves the negative paths, not just the happy one

Runs each branch of conditional logic

Coverage of a line isn’t coverage of every outcome

Uses runAs to test different user contexts

Permissions change what code can do

Tests bulk behaviour with at least 20 records

Triggers that work for one record can fail in bulk

Creates its own test data

Tests don’t depend on data in a particular org

These come from Salesforce’s own Apex testing best practices. A suite that follows them is far more valuable than one that just reaches 75%.

The practical lesson is to treat 75% as a deployment requirement, not a quality measure. Measure quality by whether the journeys the business depends on are tested end to end, and whether you can show the evidence.



How to Balance the Layers in a Salesforce Org

The classic testing pyramid says to have many unit tests, fewer integration tests and very few end-to-end tests, because end-to-end tests are slow and brittle. In a Salesforce org, that advice needs adjusting, for two reasons.

Much of the Org is Configuration, Not Code

A page layout, a permission set, a validation rule and a screen flow have no unit tests at all. If the end-to-end layer is thin, most of the org is untested.

The Cost Argument Has Changed

End-to-end tests were kept few because they were expensive to maintain. When they’re written as business intent and repaired with governance after each release, rather than rewritten by hand, that cost falls, and so does the case for keeping them few.

Salesforce Testing Pyramid

Layer

Practical Rule for Most Enterprise Orgs

Unit layers

Apex tests for every class and trigger, written to check behaviour, not just reach 75%. Jest for components with real logic. Flow Tests for record-triggered flows with branching.

Agent layer

Testing Center for every agent, with awkward and adversarial cases.

Integration layer

Integration tests for every interface where a payload or contract can change.

End-to-end layer

Journeys for everything the business would notice, such as revenue, service, onboarding, compliance and anything an auditor might ask about, run as the users who perform it.

Ownership

One person who can say which journeys are covered, at which layer, and what passed this release.



Who Owns Which Layer

Role

Owns

Contributes To

Developers

Static analysis, Apex tests, Jest tests

Integration tests

Admins

Flow Tests

End-to-end journeys for the flows they build

Agent builders

Testing Center suites

End-to-end agent journeys

Integration team

API and integration tests

End-to-end journeys that cross systems

QA or release owner

End-to-end journeys and the overall coverage picture

Every layer’s results at release time

Business users

User acceptance

Defining what correct looks like for each journey



Find the Gaps in Your Current Layers

  • List your most important business journeys, the ones customers, finance or auditors would notice.

  • For each journey, mark which layers test any part of it today.

  • Highlight journeys with no end-to-end coverage: These are your biggest risks.

  • Check Apex tests for real assertions, not just coverage, starting with classes behind those journeys.

  • Assign an owner for the overall picture, and review it every release.



What This Means for Your Regression Suite

  • Write Apex tests that check behaviour, not just reach 75% coverage.

  • Use Flow Tests for record-triggered flows with branching logic.

  • Cover validation rules, approvals and assignment rules in end-to-end journeys, as the users they apply to.

  • Treat every agent action as code to unit test and as a step in an end-to-end agent journey.

  • Give one person ownership of which journeys are covered, at which layer.



Covering the End-to-End Layer, With Virtuoso QA

The end-to-end layer is usually the thinnest, because it has been the most expensive to build and keep working. Virtuoso QA is built to change that. Admins, analysts and testers write journeys in plain English, covering validation rules, approvals, routing and integrations as the real users who perform each step. API and database steps check the data behind the screen and in connected systems.

When Salesforce or your configuration changes, steps are repaired visibly and reversibly, or proposed for someone to accept, and every run records which journeys were tested and who approved the release, so the overall picture has one place to live.

💡Virtuoso QA’s Salesforce test automation covers the end-to-end layer above Apex, Flow Tests and Testing Center, with plain English journeys run as real users across Salesforce and connected systems.



Related Reads

Salesforce Testing Layers FAQs

What code coverage does Salesforce require?

Is 75% code coverage enough?

What’s the difference between Apex tests and UI tests in Salesforce?

Do I need end-to-end tests if I have good Apex coverage?

Who should own Salesforce testing?

Written by

Rishabh Kumar

AI Testing & Quality Engineering Contributor

Rishabh leads business development and marketing at Virtuoso QA. He writes about AI-powered test automation, end-to-end testing, self-healing tests, and quality engineering, exploring how these capabilities can improve test coverage, reduce test maintenance, and support reliable software releases.

See what your next release looks like with Virtuoso

Book a walkthrough on your applications and your workflows. Bring a requirement, a user journey, or a brittle Selenium script, and watch the loop run on something you recognise.

See what your next release looks like with Virtuoso

Book a walkthrough on your applications and your workflows. Bring a requirement, a user journey, or a brittle Selenium script, and watch the loop run on something you recognise.

See what your next release looks like with Virtuoso

Book a walkthrough on your applications and your workflows. Bring a requirement, a user journey, or a brittle Selenium script, and watch the loop run on something you recognise.

Virtuoso QA is establishing the standard of proof for software releases. Its governed QA loop turns business requirements into tests for any browser-based application: AI proposes, a deterministic engine executes, a person approves what matters, and every decision leaves evidence.

Trust Center

AICPA

SOC

WAVE STRONG PERFORMER

@ Copyright 2026 SpotQA, Creators of Virtuoso QA

Virtuoso QA is establishing the standard of proof for software releases. Its governed QA loop turns business requirements into tests for any browser-based application: AI proposes, a deterministic engine executes, a person approves what matters, and every decision leaves evidence.

Trust Center

AICPA

SOC

WAVE STRONG PERFORMER

@ Copyright 2026 SpotQA, Creators of Virtuoso QA

Virtuoso QA is establishing the standard of proof for software releases. Its governed QA loop turns business requirements into tests for any browser-based application: AI proposes, a deterministic engine executes, a person approves what matters, and every decision leaves evidence.

Trust Center

AICPA

SOC

WAVE STRONG PERFORMER

@ Copyright 2026 SpotQA, Creators of Virtuoso QA

Platform

Solutions

Resources

Platform

Solutions

Resources

Platform

Solutions

Resources