Blog
Salesforce Integration Testing: APIs, Events and Systems

Rishabh Kumar
Published on

Table of contents
Salesforce rarely works alone. Leads arrive from marketing tools, orders leave for the ERP, payments come back from billing and customer data flows into analytics. Every one of those connections can break, and when it does, the problem often stays invisible in Salesforce. The record looks fine. It just never arrived where it was supposed to go.
Here I explain how to test Salesforce integrations properly. It covers the main ways Salesforce connects to other systems, what to test for each, the testing layers available, including Salesforce’s new Apex integration tests, and how to test the failures that matter most. There is a worked example and a checklist at the end.
Quick Summary
Salesforce integration testing checks the connections between Salesforce and other systems, on both sides of each connection.
Start by listing every integration your important processes depend on.
For each one, test field mapping, matching and duplicates, timing, authentication, errors, volume and access, then confirm the business outcome. Spend most of your effort on failures, such as timeouts, repeated messages, expired credentials and rejected data, because that is where incidents come from.
Use mocks for Apex logic, contract tests for formats and end-to-end journeys for whole processes. After every sandbox refresh, check that each integration still points at a test system, not production.
What is Salesforce Integration Testing?
Salesforce integration testing checks that Salesforce and the systems connected to it exchange the right data, in the right format, at the right time, and handle failures safely.
It covers inbound and outbound APIs, events, middleware and data synchronisation, and confirms that records are created, updated and matched correctly on both sides of each connection.
It sits between unit testing, which checks Salesforce logic in isolation, and end-to-end testing, which checks whole business processes as real users. Integration testing focuses on the connections themselves.
📚 For how integration testing fits alongside unit, UI and regression testing, read our guide to Salesforce testing.
How Salesforce Connects to Other Systems
Integration Pattern | How It Works | Typical Use |
|---|---|---|
Inbound APIs (REST, SOAP, Bulk) | Another system calls Salesforce’s APIs to create, read or update records | A website creating leads, or a data load from an ERP |
Outbound callouts | Salesforce calls another system’s API, usually through Named Credentials | Checking a credit score, or sending an order to an ERP |
Platform Events | Salesforce publishes or subscribes to events that other systems act on | Notifying fulfilment that an order was placed |
Change Data Capture | Salesforce publishes record changes for other systems to consume | Keeping a data warehouse in step with Salesforce |
Middleware | An integration platform, such as MuleSoft, moves and transforms data between systems | Connecting Salesforce to several back-office systems |
Salesforce Connect | External data appears in Salesforce as external objects, without being copied | Viewing ERP orders on an account page |
AppExchange packages | A vendor’s package connects Salesforce to its own service | E-signature, payments or telephony |
Most enterprise orgs use several of these at once.
Build an Integration Register First
Before deciding what to test, list every integration a business process depends on in one register. For each integration, record the pattern it uses, the direction data flows, what triggers it, the systems on each side and who owns each one, typical and peak volumes, how it handles failures, and which test environment it connects to in each sandbox. The register shows where coverage is missing, tells you whom to call when a test fails, and becomes the checklist for every sandbox refresh.
What to Test for Each Integration
Area | What to Check |
|---|---|
Data mapping | Every field arrives in the right place, in the right format, including dates, currencies, picklist values and long text. |
Matching and duplicates | Records match the right existing record on the other side, and repeated messages don’t create duplicates. |
Direction and timing | Data flows in the expected direction, and arrives within an acceptable time. |
Authentication | Credentials and tokens work, and expiry or rotation is handled. |
Errors | The integration handles timeouts, rejected data and unavailable systems without losing or corrupting data. |
Volume and limits | Bulk loads and busy periods stay within Salesforce’s API and processing limits. |
Security and access | The integration user has only the permissions it needs, and sensitive fields are protected. |
Business outcome | The process the integration supports still works, such as the order being fulfilled or the invoice being sent. |
Matching deserves special attention. Inbound integrations that upsert on an external ID field can be run twice without creating a second record, while integrations that always insert can't. Check which approach each integration uses before you design its duplicate tests.
🔔 Get ahead of platform changes with how to test Salesforce release updates before enforcement.
The Testing Layers for Salesforce Integrations
Each layer proves something different, and each has a blind spot the next layer covers.
Apex Unit Tests With Callout Mocks
These prove that Apex logic handles responses correctly, using fake responses from mock classes. They never touch the real service, so they can't catch a changed API or bad credentials.
Apex Integration Tests (Developer Preview)
These prove that Apex code works with real services, including HTTP endpoints, Agentforce and Data 360. They are a preview feature, available only in scratch orgs, and they don't run during deployments.
API and Contract Tests
These prove that the request and response formats both sides depend on still match. They don't show what users see or whether the process completes.
End-to-End Journeys
These prove the business process works across Salesforce and connected systems, as real users. They are slower and less precise about where a failure started, so they work best on top of the layers above.
Production Monitoring
This shows that real integrations stay healthy after go-live. It only catches problems after they happen, which is why it complements testing and doesn't replace it.
🔁 Find out how to keep API changes from breaking callers with API regression testing.
Salesforce's New Apex Integration Tests
Standard Apex unit tests block real callouts, so integrations have always been tested with mocks. In Summer '26, Salesforce introduced Apex integration tests as a developer preview, available in scratch orgs from API version 67.0. They let Apex tests make real calls to services such as HTTP endpoints, Agentforce and Data 360, and check the effect on org data.
Standard Apex unit tests | Apex integration tests (developer preview) | |
|---|---|---|
Annotation | @IsTest | @IntegrationTest |
External calls | Blocked, so mocks are needed | Allowed |
Shared setup data | @TestSetup, rolled back after each test method | @BeforeClass, persists between test methods |
Test data | Rolled back after each test | Committed. Clean-up runs in a @TearDown method after each test method. |
Data visibility | Isolated test data by default | Can see org data by default (SeeAllData=true) |
Code coverage | Counts towards the deployment requirement | Doesn't count |
Deployments | Run during metadata deployments | Excluded |
Execution | Synchronous or asynchronous | Asynchronous only, one run at a time per org, up to 10 minutes |
Availability | Generally available | Developer preview, in scratch orgs only |
Two details matter when you write them. To make a record visible to a service such as Agentforce within the same test, call IntegrationTest.commitTestOnly() after creating it, because uncommitted records are invisible to other services. And because data persists, keep clean-up in @TearDown and avoid deleting the records @BeforeClass created, since later test methods still need them.
These tests complement unit tests. Because the feature is in preview, Salesforce says not to use it in production work, and its behaviour may change. It is still worth trying, because it fills a gap that mocks have always left.
🧱 Place integration tests alongside Apex, Flow Tests and end-to-end journeys with Flows, Apex and triggers: where Salesforce logic lives.
Testing the Failures That Matter Most
Most integration tests check the happy path. Most integration incidents come from failures. Test these on purpose.
Failure | What should happen | How to test it |
|---|---|---|
The other system is unavailable | The message is retried or queued, and nothing is lost. | Point the integration at an unavailable endpoint in a test environment. |
The call times out | The integration retries safely, without creating duplicates. | Simulate a slow response that exceeds the timeout. |
Credentials have expired | The failure is reported clearly, and data isn't lost. | Use expired or revoked test credentials. |
The data is rejected | The rejection is logged with a reason, and someone is alerted. | Send a record with a missing or invalid required field. |
The same message arrives twice | Only one record is created or updated. | Replay the same message or event. |
Events arrive out of order | The later change wins, and an older update doesn't overwrite a newer one. | Publish two updates to the same record in reverse order. |
Salesforce limits are reached | Bulk processing slows or splits safely, instead of failing. | Run a high-volume load in a Full or Partial Copy sandbox. |
💡See how to design tests that try to break a system on purpose with negative testing.
A Worked Example: Sending Orders to an ERP
Worked example (illustrative)
When an opportunity is Closed Won, Salesforce sends the order to the ERP through middleware. The team designs six integration tests for this one connection.
Test | What It Checks | Expected Result |
|---|---|---|
Happy path | A standard order with three products | One order in the ERP, with matching products, quantities and total |
Field mapping | An order with a discount, a foreign currency and a long delivery note | Every value arrives correctly formatted, with nothing cut short |
Duplicate message | The same order event sent twice | Still only one order in the ERP |
ERP unavailable | The ERP endpoint is down for ten minutes | The order is queued, then delivered once the ERP recovers |
Rejected data | An order with an invalid product code | The order is rejected with a clear reason, and an alert is raised |
Status back to Salesforce | The ERP confirms fulfilment | The opportunity’s order status updates in Salesforce |
Only the first test is a happy path. The other five test the failures that cause most real incidents. Each one checks both sides. The duplicate test, for example, passes only when the ERP holds exactly one order and Salesforce shows exactly one confirmation.
⚖️ Dig deeper into where one ends and the other begins in end-to-end vs integration testing.
Environments for Salesforce Integration Testing
Connect each Salesforce sandbox to the test version of every connected system, never to production.
Keep endpoints and credentials out of code by using Named Credentials and External Credentials for each environment, so each sandbox connects to the right place.
Make sure the records a test needs exist on both sides, or create them as part of the test.
Use masked or synthetic data in every system involved.
🔐 Keep integration and test users signing in safely in every sandbox with handling Salesforce login, MFA and SSO in automated tests.
The Sandbox Refresh Trap
A sandbox created or refreshed from production copies its configuration, including integration settings. Unless someone changes them, a fresh sandbox can call production endpoints, so a test order can reach the real ERP.
Salesforce's SandboxPostCopy interface lets you run Apex automatically after each refresh, for example to repoint endpoints and disable outbound jobs. Even with that in place, run a quick check after every refresh that each integration in your register points at a test system and that its credentials still work, before any test runs.
🗂️ Take a look at test data management for ways to keep data consistent across connected test systems.
When to Run Salesforce Integration Tests
When integration code or mappings change, run all tests for that integration, including failure cases.
When a connected system changes, run the tests for every integration with that system.
In each Salesforce release preview window, run all integration tests plus the end-to-end journeys that depend on them.
After a sandbox refresh, run a quick check that every integration points at the right test system.
Every night, run the happy-path tests for every integration as an early warning.
📅 Plan around each preview window with Salesforce release cycle.
Common Salesforce Integration Testing Mistakes
Relying only on mocks. Mocked tests pass even when the real API has changed.
Testing only the happy path. Most incidents come from timeouts, duplicates and rejected data.
Checking only one side. A record can look right in Salesforce and be wrong, or missing, in the other system.
Using an over-privileged integration user. It hides permission problems and creates a security risk.
Forgetting limits. Integrations that work for ten records can fail for ten thousand.
Skipping the post-refresh check. A refreshed sandbox can send test data to production systems.
✅ Check out more Salesforce testing best practices that keep a suite trustworthy as the org grows.
A Salesforce Integration Testing Checklist
Every integration each important process depends on is listed.
Data mapping is tested for every field, including dates, currencies and picklists.
Matching rules and duplicate handling are tested.
Timeouts, unavailable systems, expired credentials and rejected data are all tested.
High-volume scenarios are tested against Salesforce limits.
The integration user has only the permissions it needs.
Results are checked on both sides of each connection.
Each sandbox connects only to test versions of other systems.
Integration tests run on every relevant change and in every preview window.
Salesforce Integration Testing With Virtuoso QA
An integration test only counts if it looks at the receiving system. Virtuoso QA puts the Salesforce action and the check on the other side into one journey, then files the outcome against the requirement that integration serves. A release manager can see that the order reached the ERP as well as left Salesforce, and who approved the release on that basis.
UI Step and API Check, Side by Side
A journey can create the order in Lightning, call the ERP's API and compare what arrived. API definitions live in one shared library, and existing Postman collections import directly.
Every Sandbox Points Where It Should
Each environment carries its own endpoints and credentials and inherits shared settings from a parent, which suits the post-refresh check described above. When the receiving system sits on a private network, attach a Virtuoso Bridge to that environment.
Failure Cases From a Table
Feed one journey rows of awkward values, from a CSV or generated test data, to cover mapping and rejection cases without writing new tests. Results can post to your own tooling through HMAC-signed webhooks.
💡 Pick the integration that worries you most, and let Virtuoso QA prove both ends of it in one run with Salesforce test automation.
Related Reads
Salesforce Integration Testing FAQs
What is the difference between Salesforce integration testing and end-to-end testing?
Can Apex tests make real callouts?
How do you test Platform Events and Change Data Capture?
Which sandbox should I use for integration testing?
How do you stop integration tests creating duplicate records?
How does Virtuoso QA support Salesforce integration 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.









