Integration Testing in Software Development: Types, Examples and Best Practices
What integration testing is, how it differs from unit testing, the four types (big bang, top-down, bottom-up, sandwich), examples and best practices.
Integration testing is the level of software testing that checks whether separately built modules, services and external systems work correctly together, by testing the interfaces and the data passed between them rather than each unit on its own. It sits after unit testing and before system and end-to-end testing, and it catches the bugs that only appear when one component hands data to another.
A function can pass every unit test and still fail in production because the API it calls returns a date in another format, a database rejects a null, or an ERP requires a field the code never sends. Integration testing exists to find those failures before your users do.
Where engini fits: Many of the hardest integrations to test are with systems of record: an ERP, a CRM, a bank's core system or a database behind the firewall, often called by an AI agent rather than by your own code. engini is an agent gateway that gives agents and code managed tools to read and write in those systems. For testing, a workspace has separate development, staging and production environments, any tool can be run from code with exact inputs, a connection check confirms that a sign-in still works, and every run is recorded. See the engini developer docs.
Key Takeaways
- Integration testing verifies the interfaces between components: APIs, databases, message queues, files and third-party systems.
- There are four classic approaches: big bang, top-down, bottom-up and sandwich (hybrid). Top-down uses stubs; bottom-up uses drivers.
- Narrow integration tests replace the other service with a test double and run fast; broad ones need live services and are closer to end-to-end tests.
- Contract testing, containerized dependencies and HTTP mocks make integration tests faster and less flaky in a CI pipeline.
- When the other side is an ERP or CRM, test against a sandbox, not production, and plan for what a sandbox refresh resets.
- The tools an AI agent calls are integrations too, and they need the same tests: each tool on its own first, then the agent's full loop.
What is integration testing?
Integration testing is testing two or more software components together to confirm they exchange data and control correctly. Martin Fowler describes the goal as testing "whether many separately developed modules work together as expected" (martinfowler.com).
The term covers a wide range, so Fowler separates two styles:
- Narrow integration tests exercise only the code in your service that talks to another service, and replace that other service with a test double. They are small and fast enough to run early in a deployment pipeline.
- Broad integration tests need live versions of all the services involved and a full test environment. Fowler suggests calling these system tests or end-to-end tests to avoid confusion.
Most teams need both: many narrow tests that run on every commit, and a few broad tests that run before a release.
Integration testing vs. unit testing vs. end-to-end testing
Unit tests check one function or class in isolation, integration tests check the connections between components, and end-to-end tests check a complete user journey through the whole system.
| Level | What it checks | Dependencies | Speed | Typical failure it catches |
|---|---|---|---|---|
| Unit test | One function or class | All replaced with mocks | Milliseconds | A calculation or branch is wrong |
| Integration test | Two or more components and the interface between them | Some real (database, queue), some doubled | Seconds | A field is mapped wrong, a payload is rejected, a timeout is not handled |
| End-to-end test | A full user journey | All real | Minutes | A step in the business flow breaks |
Integration tests are usually written by developers, not a separate QA team, and they run in the same CI pipeline as unit tests, often in a later stage.
Incremental vs. non-incremental integration testing
Integration testing is either non-incremental, where all modules are joined and tested at once, or incremental, where modules are added one or a few at a time.
- Non-incremental (big bang): every module is integrated after development is complete, and the whole system is tested as one block. It is simple to organize for a very small system, but when a test fails it is hard to tell which interface caused it.
- Incremental: two logically related modules are tested together first, then more are added one by one. When a test fails, the cause is usually the module or interface you just added. Missing modules are simulated with stubs (stand-ins for lower-level modules) and drivers (stand-ins for higher-level callers).
Types of integration testing
The four classic types of integration testing are big bang, top-down, bottom-up and sandwich. Contract testing is a newer approach that is common in microservices.
| Type | How it works | Uses | Strength | Weakness |
|---|---|---|---|---|
| Big bang | All modules integrated and tested at once | Nothing simulated | Little planning for small systems | Failures are hard to isolate; testing starts late |
| Top-down | Starts with high-level modules, adds lower ones step by step | Stubs for lower modules not yet integrated | Main control flow and design flaws show up early | Stubs take work to write and maintain; low-level modules are tested late |
| Bottom-up | Starts with low-level modules (data access, utilities), adds higher ones | Drivers that call the modules under test | Foundation and data handling tested early and thoroughly | The overall flow is only seen at the end |
| Sandwich (hybrid) | Top-down and bottom-up run in parallel and meet in a middle layer | Stubs and drivers | Covers both ends early in large systems | Needs more people and coordination |
| Contract testing | Each service is tested on its own against a shared contract of the requests and responses it expects | A recorded contract instead of a live service | Catches breaking API changes without deploying every service | Does not test business behavior across the whole flow |
Pact, a widely used contract testing tool, defines contract testing as "a technique for testing an integration point by checking each application in isolation" against a shared contract (Pact docs).
Tip: In a system built from many services, a common mix is contract tests between services, narrow integration tests for each service's database and external APIs, and a small number of broad end-to-end tests for the flows that make money.
How to do integration testing, step by step
A good integration test plan starts from the interfaces, not from the modules.
- List the interfaces. Write down every point where data crosses a boundary: service to service, service to database, service to queue, service to third-party API, file drops, webhooks. For each, note the format, the authentication and who owns the other side.
- Choose the approach. Pick incremental (top-down, bottom-up or sandwich) for anything larger than a few modules. Add contract tests where separate teams own each side of an API.
- Decide what is real and what is doubled. Use real instances for what you own and can run locally, such as your database. Use mocks or stubs for third-party APIs you cannot control, and a vendor sandbox for systems of record.
- Write the test cases. Cover the happy path, invalid input, missing and extra fields, large payloads, duplicates, timeouts, rate limits and expired credentials. Check what lands on the other side, not only the response code.
- Prepare test data. Create the records each test needs and clean them up after, so tests do not depend on each other or on leftovers from earlier runs.
- Run the tests in CI. Run narrow integration tests on every pull request and broad ones on a schedule or before a release.
- Log, fix and re-run. When a test fails, record which interface failed and why, fix it, and keep the test as a regression test so the same break cannot return unnoticed.
Integration testing examples
These two examples show what an integration test checks in practice.
Example 1: an e-commerce order
Placing an order touches four services, connected by APIs or webhooks:
- Inventory service: checks that the product is in stock and reserves it.
- Payment gateway: an external API that authorizes the card.
- Shipping service: calculates delivery options and cost.
- Notification service: sends the confirmation email.
The integration tests confirm that when the payment succeeds, the stock is reduced, the shipment is created and the email goes out, in that order and with the same order ID. They also confirm the failure paths: a declined payment releases the reserved stock, and a timeout from the payment gateway does not create a duplicate charge on retry.
Example 2: a closed deal that becomes a sales order
When a sales rep marks an opportunity as won in the CRM, an integration creates the customer and the sales order in the ERP. The integration tests check that:
- the customer is created once, even if the trigger fires twice;
- custom fields in the ERP that are required on a sales order are filled in;
- currency, tax and subsidiary values map correctly;
- a rejected write in the ERP is reported back, not silently dropped.
This kind of test needs a real ERP and CRM account to run against, which is what vendor sandboxes are for.
Testing integrations with ERPs and CRMs
For integrations with systems of record, run integration tests against the vendor's sandbox, never against production.
Salesforce describes a sandbox as a replica of your production org that you can use for development, testing and training without affecting live users or data (Salesforce). Salesforce offers four types:
| Salesforce sandbox | What it copies from production | Refresh interval |
|---|---|---|
| Developer | Metadata only | Once per day |
| Developer Pro | Metadata only, more storage | Once per day |
| Partial Copy | Metadata and a sample of data defined by a template | Every 5 days |
| Full | Metadata, all data and files | Every 29 days |
Oracle NetSuite says a sandbox lets you "safely test and develop new applications and customizations without affecting your production account", and that each sandbox has the same setup, data and customizations as production. Oracle lists "trying out third-party integration features" among its uses (NetSuite Help Center).
Two things catch teams out:
- A refresh resets the sandbox. NetSuite notes that during a sandbox refresh, production data overwrites sandbox content, and integration records copied from production arrive with their production settings (NetSuite Help Center). Plan to re-check credentials and integration records after every refresh. Our guide on fixing integrations after a NetSuite sandbox refresh covers the steps.
- The sandbox may not match production's API version or limits. Check the API version your integration calls, and see our notes on Salesforce API version deprecation.
Integration testing tools
Most integration test suites combine a test framework, a way to run real dependencies, and a way to fake the ones you cannot run.
| Tool | What it does in integration tests |
|---|---|
| pytest (Python), JUnit (Java) | Test frameworks that run integration tests in CI alongside unit tests |
| Testcontainers | An open source library for throwaway instances of databases, message brokers and other services in Docker containers |
| WireMock | Simulates HTTP APIs, so a test does not depend on a third party being up |
| Pact | Consumer-driven contract testing for HTTP and message integrations |
| Postman | API testing, mock servers and collection runs |
| Playwright | Browser automation for tests that go from the user interface to the backend |
Integration testing best practices
The practices that make the biggest difference are the ones that keep tests fast, repeatable and honest about failure.
- Prefer many narrow tests to a few broad ones. Narrow tests with real databases in containers and mocked third parties run on every commit. Keep broad end-to-end tests for the critical flows.
- Test the failure paths. Timeouts, rate limits, expired tokens, partial writes and retries cause more production incidents than the happy path.
- Make writes idempotent and test it. Run the same event twice and confirm you get one record, not two.
- Own your test data. Create what each test needs, clean it up after, and never point a write test at production data.
- Pin the contract. Use contract tests or schema checks so a change on one side of an API fails a build instead of a customer's order.
- Fix flaky tests at the cause. Flakiness usually comes from shared state, real third-party calls or timing. Replace those with containers, mocks and explicit waits.
- Keep tests close to the code. The team that changes an interface should be the team that sees its integration test fail. This fits naturally with test-driven development.
Testing integrations that AI agents call
When an AI agent creates a bill in an ERP or updates a record in a CRM, each tool it calls is an integration, and it needs the same tests as any other. The difference is that the model decides which tool to call and with which inputs, so you test in two layers:
- Test each tool deterministically. Call the tool from code with exact inputs against a sandbox connection, and assert on what was written. No model is involved, so the test is repeatable.
- Then test the agent's loop. Give the agent a goal and a limited set of tools, run it against the sandbox, and check both the result and the record of which tools it called.
A rule written in the prompt, such as "never delete records", is a request to the model. A limit enforced by the system the agent calls through is something you can test: call a tool outside the agent's allowed set and confirm the call is refused.
How engini helps you test integrations with systems of record
engini is an agent gateway between AI agents (or your own code) and the systems they act in: ERPs and CRMs such as NetSuite, SAP, Priority and Salesforce, complex financial and legacy systems, databases, files, and systems behind the firewall through an on-premises agent that opens the connection from inside your network. These are what engini gives you for integration testing:
- Separate environments. A workspace has development, staging and production environments, and an API key is tied to one workspace and one environment (API keys). Point the development environment at sandbox connections and production at production.
- Deterministic tool runs. From the Python or TypeScript SDK, the REST API or the CLI, you can run one action with exact inputs and no model choosing it, which is the shape of an integration test (scripted automation).
- Connection checks. A connection check confirms that a connection's stored credentials still sign in, which is useful after a sandbox refresh (check connection).
- Your real setup. Custom fields and custom objects are read live from each system's own configuration, so tests run against the fields your account actually has.
- Toolsets. A toolset limits an agent to the tools and the connection you choose, for example read only, and engini enforces it on the server for SDK, API and CLI calls (scope an agent with a toolset).
- A record of every run. Every run is recorded under the user who triggered it, and the audit log can be exported or streamed to a SIEM, so you can see exactly what a test wrote.
When you do not need engini: unit and integration tests between services you own, or a simple sync between two SaaS apps with no system of record involved, are covered well by the tools in the table above. engini matters when the other side is an ERP, CRM, core banking or legacy system, or when an AI agent is the caller.
To start, read the engini developer docs or point your coding agent at docs.engini.ai/llms.txt. For the bigger picture of connecting business systems, see our guide to ERP integration.
Agent gateway
Ship agents into systems you can’t afford to break
Connect AI agents to your ERP, CRM, financial and legacy systems through MCP, SDK, API or canvas, with secure auth, tool permissions and an audit trail built in.
Frequently Asked Questions
What is integration testing in simple terms?
Integration testing checks that separately built parts of a system work correctly when they are connected. It tests the interfaces between them, such as API calls, database queries and messages, rather than each part alone.
What is the difference between integration testing and unit testing?
Unit testing checks one function or class in isolation, while integration testing checks how several components behave together. Many bugs only appear at the boundary, for example when a real database or external API returns data the code did not expect.
What are the types of integration testing?
The four classic types are big bang, top-down, bottom-up and sandwich (hybrid). Microservice teams often add contract testing, which checks each service against a shared API contract without deploying every service.
What is a stub vs. a driver in integration testing?
A stub replaces a lower-level module that is not ready yet, and is used in top-down testing. A driver replaces a higher-level caller, and is used in bottom-up testing to call the module under test.
When should you use big bang integration testing?
Use big bang integration testing only for small systems where all modules are finished and there are few interfaces. In larger systems, failures are hard to trace, so incremental approaches work better.
How do you run integration tests in a CI/CD pipeline without flaky tests?
Run real dependencies such as databases in containers, replace third-party APIs with mocks or contract tests, and give each test its own data. Most flaky integration tests come from shared state, live external calls or timing.
Sources
- Martin Fowler: IntegrationTest
- Pact documentation: contract testing
- Testcontainers
- WireMock
- pytest documentation
- JUnit
- Postman API testing
- Playwright
- Salesforce: What is a Salesforce sandbox?
- Oracle NetSuite Help Center: NetSuite Sandbox
- Oracle NetSuite Help Center: Using Integration Records in Sandbox Accounts
- engini developer docs