On this page
- What is microservices testing?
- Microservices testing vs testing a monolith
- The testing pyramid for microservices
- How to test microservices, step by step
- Integration testing for microservices
- End-to-end testing microservices
- Testing synchronous and asynchronous flows in microservices
- Testing microservices with real databases, queues and workflows
- Performance, chaos and security testing for microservices
- What AI coding agents change about testing microservices
- Do you need a staging environment to test microservices at all?
- Building a microservices testing strategy
- Test automation tools vs environment platforms
- Microservices testing best practices checklist
- How lightweight ephemeral environments keep every test running against current dependencies
- Where to go next
Microservices testing checks that each service in a distributed system works on its own, and that the services keep working when they call each other, publish to queues and run workflows together. Testing microservices is mostly about those interactions, because a microservices architecture moves correctness out of any single codebase and into the seams between services that different teams build, deploy and change on different schedules.
The biggest risk isn’t a missing test. It’s a suite that passes at every layer while the thing it ran against no longer matches production: a mock written against last quarter’s API, a staging environment three deploys behind, a dependency that changed its response shape on Tuesday. Coding agents add a second risk. They write changes that are complete inside one service and incomplete across the services around it.
So how to test microservices comes down to two decisions: which tests each layer needs, and what each test runs against. The complete guide to Kubernetes testing covers the cluster those tests run on.
What is microservices testing?
Microservices testing is the practice of verifying two things: that an individual service behaves correctly in isolation, and that the system behaves correctly when services interact. Unit and component tests cover the first. Contract, integration and end-to-end tests cover the second, and performance, chaos and security tests check how the whole system holds up under load, under failure and under attack.
People also call it testing microservices, microservice testing, testing in microservices or distributed systems testing. The practice is the same under each name.
It catches three classes of problem before users do: logic bugs inside a service, contract breaks between services, and behavior that only appears when real services run together under real conditions. It isn’t a substitute for observability in production, and it doesn’t prove a system correct. It narrows the gap between what a test checked and what will run.
Kubernetes made this the default problem rather than a niche one. The CNCF’s 2025 annual survey, published in January 2026, found that 82 percent of container users now run Kubernetes in production. Most of those systems are services that call each other, so most of them need a testing strategy for the calls.
Microservices testing vs testing a monolith
Testing a monolith is mostly about covering logic inside one codebase, where a changed function signature breaks the build. Microservices testing is mostly about covering interactions, because the same call now crosses a network to a service on another version, owned by another team, and it breaks at runtime instead. Even a small system shows where the work moves.
| What changes | Monolith | Microservices |
|---|---|---|
| Where bugs live | Inside functions | In the calls and messages between services |
| When a broken interface fails | At build time | At runtime, in whichever environment first runs both versions together |
| Versions under test | One version of everything | A mix of versions nobody tested together, because services deploy independently |
| The network | Not involved | Slow calls, partial failures, retries and duplicate deliveries |
| Data | One database, one transaction | Each service owns its data, so one workflow spans several databases |
| Asynchronous work | A call stack to follow | A message whose consumer the producer's test never sees |
| Test environment | One process, one build | Many services, usually on one environment that many teams deploy to |
The table explains where the test budget moves. In a monolith, unit test coverage tracks most of the risk. In microservices, the expensive failures sit at the seams, so the layer that tests interactions against real services carries more weight.
The last row matters as much as the others. A test that fails on an environment twenty other changes share could have been broken by any of them, so every failure there starts with an investigation of whose it is.
The testing pyramid for microservices
The microservices testing pyramid has five layers rather than the classic three: unit, contract, integration, end to end, and production checks. The two extra layers exist because two new failure modes appear between a unit that works and a system that works. A service’s API can drift from what its callers expect, and a release can behave differently under real traffic than under any test traffic.
| Layer | What it checks | What it runs against | What it misses | Typical tools |
|---|---|---|---|---|
| Unit | A single function or class in isolation, with no network calls | Nothing external, only in-process fakes | Whether two services still agree on how to talk to each other | JUnit, pytest, Go testing, Jest |
| Contract | That a service's API or messages still match what its consumers expect: request shapes, response fields, status codes, event payloads | A recorded specification of the other service, not the running service | How the service behaves under real conditions, past the shape of its responses | Pact, Specmatic |
| Integration | Real calls and messages between services at the versions deployed | Live dependencies at their current versions, most reliably a per-change environment on a shared cluster | Full user journeys spanning the interface and every downstream service at once | Language test frameworks, Testkube to run them in the cluster |
| End to end | A complete user journey across every service it touches, treating the system as a black box | A fully deployed system | Little, but slowly and expensively, and a failure rarely says which service caused it | Cypress, Playwright, Selenium |
| Production checks | That a release behaves correctly under real traffic | Production, on a slice of real users | Nothing, but it finds problems after users have already met them | Canary deploys, feature flags, synthetic checks |
The layers aren’t interchangeable. A thousand unit tests say nothing about whether the orders service still returns the field the checkout service reads, and a passing contract test says nothing about what happens when the real orders service is slow.
The integration layer also carries more weight than the pyramid’s shape suggests. Interactions are where distributed systems fail, so the layer that tests them against real services catches the most expensive bugs. It’s also the hardest layer to keep trustworthy, because an integration test is only as good as the dependencies it runs against. Is the testing pyramid broken? argues that the classic shape undersells it.
Performance, chaos and security tests cut across the layers instead of sitting on one. They run anywhere from a unit benchmark to a production game day, and the section on them covers where each pays off.
How to test microservices, step by step
You test microservices in four stages: unit and local integration checks in the editor, integration tests against live dependencies at the pull request, end-to-end and performance tests before release, and production checks under real traffic. Each stage catches a different class of problem, and each depends on the one before it having done its job.
1. Local development: test the one service you changed against real neighbors
Start with unit tests for the logic you touched. They run in seconds, need no infrastructure, and should be the first thing that fails when you break something.
The harder question is what to do about dependencies. Running fifty services on a laptop stops working past a handful, and Docker Compose files that recreate the system fall out of date as fast as the system changes. The alternative is to run only the service you’re changing and connect it to a shared Kubernetes cluster that already runs the current version of everything else.
Telepresence and mirrord do this by intercepting traffic, and a lightweight ephemeral environment does it by sending tagged requests to your local process. The local development on Kubernetes guide compares the options.
2. Pull request and CI: run integration tests against current dependencies before merge
CI should run the unit suite, then the integration tests for the services the change touches. The second part is where most pipelines fall short. CI runners start with no dependencies. So teams either mock everything, which defeats the point of an integration test, or defer it to staging, the slowest and most contended point in the pipeline.
The fix is an isolated place per pull request to run against live dependencies. A lightweight ephemeral environment deploys only the changed services into a shared cluster, while every other call reaches the shared copies at their current versions. Contract tests belong at this stage too, since they need nothing live and catch a narrower class of break earlier. Levo cut its integration-testing time by 90% after it moved its automated end-to-end tests to run this way before every merge.
3. Before release: end-to-end and performance tests on the paths that matter
Before release, run the thin end-to-end suite for the journeys that carry revenue or trust, and a performance check on the paths the change touched. Both need the whole system, so the environment they run in decides how much a pass is worth. The end-to-end and load testing sections cover each.
4. Production: verify under real traffic and limit the blast radius
Some behavior only appears under production traffic: real data shapes, real concurrency, real third-party latency. That’s why production checks sit at the top of the pyramid.
Canary deployments send a small slice of traffic to the new version and compare error rates and latency before widening. Feature flags separate deploying code from enabling it, and synthetic checks run scripted journeys against production on a schedule. None of these replace the earlier layers. A team that leans on them to catch integration bugs pays for those bugs in incidents, which feature flags versus preview environments explores.
Integration testing for microservices
Integration testing checks that two or more real services behave correctly when they call each other. Microservices integration testing is the layer that catches seam failures, and the choice of what it runs against makes or breaks the result. Run on every pull request as a required check, it is the core of pre-merge verification.
Mocks versus live dependencies
A mock stands in for a dependency and returns canned responses. Mocks are fast, deterministic and need no infrastructure, which is why WireMock and MockServer are on most shortlists. They’re the right tool for unit and component tests, and for third-party APIs you can’t call from a test, which mocking third-party APIs in an ephemeral environment covers.
They’re the wrong tool for verifying integration between your own services. A mock encodes what one team believed the other team’s API did on the day the mock was written. The other team keeps shipping, nothing updates the mock, and nothing fails when the two diverge.
The tests keep passing against a version of the dependency that no longer exists. Why integration tests pass with mocks and still break in staging traces that failure step by step. The guide to mocks versus production-like environments covers when each one is the right call.
Contract tests narrow the gap without closing it
Contract tests are the disciplined middle ground. The consumer publishes what it expects, the provider checks it can meet those expectations, and a broker tracks which versions are compatible. They catch breaking API changes before merge without a live dependency.
What they don’t catch is behavior. A provider can satisfy every contract and still return the wrong data, time out under load, or fail on the third retry. Contract tests check the shape of the conversation, and integration tests check the conversation itself, so most teams run both. The complete guide to contract testing covers consumer-driven and provider-driven contracts and the tools.
Where the live dependencies come from
If integration tests need live dependencies at current versions, something has to provide them. There are three models, and they differ in cost, in how far they drift, and in what they require of your services.
| Model | How it supplies live dependencies | Where it breaks | Prerequisites | Best fit |
|---|---|---|---|---|
| Shared staging environment | One deployed copy of every service that all teams test against | Becomes a queue past a few teams, and drifts from production once keeping it in sync is nobody's job | A CD pipeline that deploys to it | Under ten services with one or two teams |
| Full-stack ephemeral environment per change | A fresh copy of every service for every pull request | Each copy costs as much as staging, takes as long to build as the whole system, and starts drifting once it exists | Namespace or cluster automation, seeded data per copy, a budget that scales with pull requests | Small systems, or changes that touch most services at once |
| Lightweight ephemeral environment on a shared cluster | Deploys only the changed services and sends everything else to the shared copies already running | Needs a routing header propagated through every service, and stateful side effects isolated on purpose | Header or trace-context propagation across services, a proxy or service mesh | Ten or more services, multiple teams, or coding agents opening pull requests |
Both ephemeral models are ephemeral environments: the first copies the stack per change, the second runs only what changed. The second is the only model whose dependencies stay current on their own, because the CD pipeline already keeps the one shared set current and each change gets an isolated slice of it.
The prerequisite is real, though. If a service drops the routing header on the way through, requests behind it fall back to the shared copies silently, and the test passes against the wrong version without saying so.
End-to-end testing microservices
End-to-end testing microservices means driving one complete user journey through every service it touches and checking what the user sees. It’s the only test that proves the services work together as a product, and the most expensive one to run and debug, so the suite should stay thin.
- Pick the journeys. The handful that carry revenue or trust, such as sign-up, checkout, a payment and a refund. Leave edge cases to integration tests, which fail closer to the cause.
- Drive them from the outside. Playwright or Cypress from the UI, or an API client against the public gateway.
- Own the test data. Each run creates and tags the users, carts and accounts it needs, so two runs never read each other’s records.
- Wait for outcomes, not for time. When a step goes through a queue or a workflow, poll for the result with a deadline. Fixed sleeps are a common source of flaky end-to-end tests, because the right wait changes with load.
- Run against one change at a time. A failure on a shared environment could belong to any change deployed there. A failure in an environment that holds one change belongs to that change.
The traditional place to run them is a staging environment, which works until the teams sharing it turn it into a queue and until it drifts from production. The alternative is an environment per change, which is where shifting end-to-end testing left on microservices starts.
Testing synchronous and asynchronous flows in microservices
Synchronous and asynchronous flows fail in different ways, so they need different tests. A REST or gRPC call fails while the caller waits, and the error comes back up the chain. A flow through Kafka, SQS, RabbitMQ or Pub/Sub fails after the producer has moved on, so the producer’s test passes and the failure shows up later, in another service.
Most systems use both, often in one user journey. The guide to how microservices communicate covers the protocols themselves.
Testing synchronous call chains: REST and gRPC
A synchronous chain fails at the seam between two services: a renamed field, a changed status code, a timeout shorter than the other side’s retries. Four checks catch most of it.
- Schema compatibility before merge. For gRPC,
buf breakingfails the build on a breaking Protobuf change. For REST, a consumer-driven contract or an OpenAPI diff does the same job. - The real chain at the pull request. Send requests through the changed service and the real services it calls. Timeouts, retries and wrong values in correctly shaped fields show up here and nowhere earlier.
- Failure paths. Make a dependency slow or return errors, and check that the caller times out before its own caller does and never retries a call that isn’t idempotent.
- Header propagation. Trace and routing headers have to survive every hop. grpcurl calls a gRPC service by hand with the headers set. To check whether your tracer and language carry them at all, contextpropagation.io tests trace context and baggage across HTTP, gRPC, Kafka and RabbitMQ hops.
Testing asynchronous flows: Kafka, SQS, RabbitMQ and Pub/Sub
Testing async microservices starts from one fact: an asynchronous flow has no call stack to follow. The producer’s test can only prove that it published.
- Assert on the effect, not the publish. Publish a real message to a real broker and assert on what the consumer did: the row it wrote, the event it emitted. Poll for it with a deadline.
- Test redelivery and ordering on purpose. Deliver the same message twice and out of order. Brokers do both in production.
- Check message contracts. Pact supports message pacts, and an AsyncAPI document describes channels and payloads the way OpenAPI describes endpoints.
- Keep each test’s messages apart. On a shared broker, a consumer under test will process another team’s messages, and the stable consumer will process the test’s. Give the test its own topic, or tag each message with a routing key so only the consumer under test picks it up.
The routing-key approach keeps one broker for everyone. Message isolation for Kafka, SQS and more maps it onto each broker, and the Kafka tutorial walks through a working setup.
Testing microservices with real databases, queues and workflows
Mocks miss the bugs that live in state and in asynchronous handoffs: a migration that breaks a service still on the old schema, a consumer that misreads a renamed field, a workflow step that runs twice on retry. Catching them takes the real database, broker and workflow engine in the test, with each change’s use of them kept apart from everyone else’s.
Testing durable workflows
Durable workflow engines survive crashes by recording each step and replaying the record, and that makes them harder to test than a plain service. Replay has to be deterministic, so a change that reorders steps can break every workflow already in flight. Workflows outlive deploys, retry failed steps on their own, and treat time as logic.
Test them in two steps. First, the workflow logic with the engine’s own tools: a test server that skips time, and a replay of recorded histories against the new code, both in CI with no cluster. Second, the changed code against the real services its steps call. The Temporal workers tutorial shows the second step with the engine left shared: work started by the change carries its routing key, and only the changed worker picks it up.
How to give each change real state without copying everything
A full copy of every database, broker and workflow cluster per pull request is the slowest, most expensive part of a full-stack environment, and most changes don’t need it. Three ways keep a test’s state apart, from cheapest to most isolated:
- Share the stable copy and partition it. Tests write under their own tenant or user and clean up after themselves. This covers most changes that read data or add rows.
- Share the broker or task queue and route by key. The consumer or worker under test handles only work carrying the change’s routing key, and the stable versions handle the rest.
- Give the change its own copy. A schema change or destructive test gets a temporary database, schema or branch, created with the environment and deleted with it.
The ephemeral environments guide covers each mechanism. How Bitso branches a Neon database for every environment shows the third in production use.
Performance, chaos and security testing for microservices
Performance, chaos and security tests check properties of the whole system: how fast it is under load, how it behaves when a dependency fails, and whether one service can reach data it shouldn’t. In microservices each property lives in the calls between services, so each test needs real services to call.
| Test | What it finds in microservices | Where it runs | Tools |
|---|---|---|---|
| Performance and load | Latency that adds up along a call chain, a new loop that calls a downstream service once per item, connection pool limits, consumers falling behind a topic | Per change against the changed service, and at full scale in an environment sized like production | Grafana k6, Gatling, Apache JMeter, Locust |
| Chaos | Missing timeouts, retry storms, fallbacks that never fire, one slow dependency taking down its callers | Per change for a single injected fault, and as scheduled experiments in pre-production and production | Toxiproxy, Istio fault injection, Chaos Mesh, LitmusChaos, AWS Fault Injection Service, Gremlin |
| Security | Broken authorization between services, internal APIs open to any caller, vulnerable images, misconfigured clusters | Static checks in the editor and CI, dynamic tests against running services | Semgrep, Trivy, kube-bench, ZAP |
How to load test microservices
Load testing microservices has two jobs that need two setups. The first is catching regressions: did this change make the checkout path slower? That test is small and runs on every pull request, through the changed service and the real services behind it. Compare the result with the shared version measured at the same time, since shared dependencies move under load.
The second job is capacity: how much traffic the system takes before it degrades. That needs an environment sized like production with nothing else on it, and it runs before a launch, not on every change. Grafana k6 has a gRPC client built in, and Gatling, Apache JMeter and Locust cover the same ground. The k6 tutorial walks through the per-change setup.
Chaos and security testing
Chaos testing injects latency, errors or a killed pod to check that the system degrades the way its design says it should. Start per change, with a fault between the changed service and one dependency through Toxiproxy or fault injection in Istio, scoped to that change’s path so other teams’ tests don’t fail with it. Cluster-wide experiments belong in scheduled runs with Chaos Mesh or LitmusChaos.
Security testing adds a question a monolith never had: which service may call which, with what data? The first risk on the OWASP API Security Top 10, last revised in 2023, is broken object level authorization. Inside a cluster, internal APIs are often called with no authorization at all. Call each service as the wrong user and as the wrong service, and expect a refusal from real services where the mesh’s policies apply.
What AI coding agents change about testing microservices
Coding agents change microservices testing because they work one service at a time, while the change that breaks things often has a second half in another service. They also need the test environment themselves, on their own schedule, with no person in the loop.
Agents finish the change they can see
An agent works inside one repository’s context. In a microservices system, the caller that reads a renamed field, the consumer that parses an event, or the workflow that calls the endpoint usually lives in another service the agent never opened. Its unit tests pass, because inside its service the change is complete.
Brandon Foley’s benchmark of three agent setups on real Kubernetes bug reports, published on the CNCF blog in May 2026, found the same pattern inside one large codebase. The biggest failure mode wasn’t incorrect fixes but incomplete ones. In his words, agents “fix symptoms in isolation, but miss the contracts between components.” Split that codebase across services and repositories, and the missing half becomes a runtime failure in someone else’s service.
The fix is to run the agent’s change against the real neighbors before review, in an environment the agent creates itself through a CLI, an API or an MCP server. When a change spans services, the pull requests for each part need to be tested together, in one environment, before any of them merges.
What agents make easier
Agents also remove excuses that kept the integration layer thin. Writing an integration test, a contract test or a message pact is cheap for an agent, and so is updating a mock when the service it imitates changes. Agents like Claude Code and Windsurf can run many isolated test runs in parallel without anyone waiting on a staging slot.
What doesn’t get easier is deciding what the system should do. Someone still has to own the end-to-end journeys and the contracts between teams. Verifying AI-generated code on Kubernetes walks through how an agent reads a failed integration run and iterates on it.
Do you need a staging environment to test microservices at all?
You need what staging is for: a shared environment where a change meets the current versions of everything it depends on before users do. What stops working past a few teams is giving that environment to one change at a time. The argument that staging is dead is right that one shared copy becomes a queue, and wrong when it concludes that mocks, contracts and canaries can replace the integration layer.
Under about ten services with one or two teams, one shared staging environment is still the right answer. Past that, keep the shared environment and change how changes use it: each one gets an isolated slice of it rather than a turn on it. Wealthsimple cut its weekly staging deployments from 260 to 134 after developers got isolated environments to test in. Kubernetes staging environments covers how teams make that move without a flag day.
Running the shared test environment like a product
The shared environment behind any of these models needs an owner, a definition of current, and a way to tell whose change broke what. It’s a platform team’s product, with a stated limit on how far behind the main branch it may fall and an alert when it does. The same CD pipeline that deploys production deploys it, from the same images and configuration, so the two can’t diverge by hand.
Access decides whether it gets used. QA, product owners and reviewers need a URL per change, and developers need to connect a local process from their editor. Agents need the same through a CLI or MCP, with a time-to-live on everything they create.
Building a microservices testing strategy
A microservices testing strategy is the decision about how much to invest at each layer of the pyramid, and where the integration layer gets its live dependencies. Most strategies come down to four questions, and two checks show whether the answers hold.
How many services, and how many teams own them?
Below about ten services with one or two teams, a shared staging environment and a thin end-to-end suite usually work, because everyone can see the whole system. Past that, staging becomes a queue and drift becomes invisible. That’s where integration testing needs an isolated place to run per change, and where copying environments versus sharing one becomes the central decision.
How do your services talk to each other?
A system built mostly on synchronous calls puts its weight on integration tests of call chains and on contract checks for each API. A system built on Kafka, a queue or a workflow engine needs message and workflow tests at the pull request too, plus chaos tests for redelivery and retries. Map the flows first, then decide which synchronous and asynchronous tests each one needs.
Where do failures come from?
Pull the last quarter’s production incidents and sort them: bugs inside one service, failures at a seam between two, and configuration or environment differences. Teams that do this usually find the second and third categories dominate while their test investment still sits in the first. If that’s your result, move effort up the pyramid and make every pull request run its integration tests before merge.
How fast is the change rate growing?
A pipeline sized for today’s pull request volume will be undersized within a year for most teams, and within months for teams adopting coding agents. The cost model decides whether that’s affordable. A full copy per change scales cost with the number of pull requests, while a lightweight ephemeral environment scales it with the number of changed services in each one.
Shift-left testing for microservices
Shift-left testing means running each layer at the earliest stage that can support it. For microservices the shift that pays most is moving integration tests from staging to the pull request, where seam failures are cheapest to fix. The guide to shift-left testing in Kubernetes covers which tests move and what the pull request environment has to provide.
How do you know the strategy is working?
Measure it with the four DORA metrics. Moving integration tests to the pull request should show up as shorter lead time and a lower change failure rate within a quarter. If change failure rate doesn’t move, the tests still run against the wrong dependencies. If lead time doesn’t move, the environment is still a queue.
Test automation tools vs environment platforms
Microservices testing needs two layers of tooling that teams often confuse. Test automation tools write, run and orchestrate the tests. Environment platforms give each change somewhere real to run them, against current dependencies and isolated from other changes. Most teams need one from each layer, and two tools from the same layer still leave the other gap.
| Layer | The question it answers | Examples | What it leaves to the other layer |
|---|---|---|---|
| Test automation and orchestration | What do we test, and how do the tests run and report? | JUnit or pytest, Pact and Specmatic, Playwright and Cypress, k6 and JMeter, Testkube to run them in the cluster | The services under test, their dependencies, and keeping both current |
| Environment platforms | Where does this change run, against which versions of its dependencies, isolated from every other change? | Signadot, Release, Bunnyshell, Okteto, Qovery, or an in-house namespace per pull request | What to test, and whether the change works |
The layers meet at running the tests. An orchestrator such as Testkube runs suites inside the cluster but expects the environment to exist already. Signadot can run a suite as a Job in pods next to the environment, for teams with nowhere else to run it. Keep one place that runs and reports tests, pointed at each change’s environment.
The survey of microservices testing tools for Kubernetes compares the field tool by tool. For contracts, Signadot versus Pact covers where contract tests stop and live integration tests start.
Microservices testing best practices checklist
Twelve yes-or-no questions. A team that answers yes to all of them has closed the gap between a passing suite and a working system.
- Does every service have fast unit tests that run in the editor and in CI?
- Do contract tests run before merge for every API and event another team consumes?
- Does every pull request run integration tests against live dependencies before a human reviews it?
- Are those dependencies at their current versions, kept in sync by the same pipeline that deploys production?
- Can two changes to the same service be tested at the same time without interfering?
- Does each change that writes data get its own isolated schema or database?
- Do async flows through Kafka, a queue, or a durable workflow engine get the same isolation as synchronous calls?
- Is your end-to-end suite thin enough that a failure is investigated the same day, and does it wait on outcomes rather than fixed sleeps?
- Do latency-sensitive paths get a performance check on every change, and critical dependencies a fault-injection test for timeouts and retries?
- Is authorization between services tested, rather than assumed because the caller is inside the cluster?
- Can developers and coding agents create, test against, and destroy an environment on their own, with a time-to-live on each one?
- When an integration test fails, does tracing point at the one service that changed?
How lightweight ephemeral environments keep every test running against current dependencies
A lightweight ephemeral environment keeps tests current by giving every change its own isolated copy of only the services it touched, running against the shared versions of everything else. This is what Signadot does, and the microservices testing solution page covers how teams adopt it.
The mechanism, in plain words: fork only the services that changed, send everything else to the shared running copies, isolate stateful side effects when a change needs it, and manage the lifecycle through the CLI, the API or MCP. One Kubernetes cluster runs the current version of every service, kept current by the same CD pipeline that deploys production. Each environment is a Sandbox, Signadot’s lightweight ephemeral environment, and it expires on a time-to-live or is deleted with the pull request.
Each test request carries its Sandbox’s routing key in a header, and a service mesh or Signadot’s DevMesh sidecar sends it to the forked service while every other call reaches the shared copy. The same key travels through message queues and Temporal task queues. A Sandbox that needs its own database, queue or bucket declares it as a resource, created with the Sandbox and deleted with it.
An integration test for a two-line change therefore runs against every other service at its current version without deploying any of them, and cost scales with changed services rather than total services. Brex saves about $2 million a year in infrastructure compared with duplicating environments per change. When every test runs against current dependencies, a passing suite is close enough to a working system to trust, and it stays that close as the number of services and authors grows.
Where to go next
If you run fewer than ten services and staging still works, read the staging environments guide and keep it healthy. If staging has become a queue, start with the ephemeral environments guide. If most of your flows run through Kafka or a workflow engine, start with asynchronous flows and durable workflows above. If agents open your pull requests, start with the agent section, because the pipeline you build for them is the one everyone else ends up using.
Related reading
- Contract testing: the complete guide
- Kubernetes testing: the complete guide
- Is the testing pyramid broken?
- Integration tests pass with mocks but staging still breaks: how to catch it earlier
- Verifying AI-generated code: the complete guide
- Shifting end-to-end testing left on microservices
- How microservices communicate with each other
- Local development on Kubernetes: the complete guide
- Shift-left testing for Kubernetes microservices: what moves to the pull request
- Best microservices testing tools for Kubernetes in 2026
- Microservices testing for FinTech
- Testing microservices: message isolation for Kafka, SQS, more
- Tutorial: Testing Kafka-Based Microservices in Kubernetes
- Tutorial: Test Temporal Workers on Kubernetes
- Tutorial: Load Testing Pull Requests with Grafana k6
Frequently asked questions
What is microservices testing, and how is it different from testing a monolith?
Microservices testing checks that each service works on its own and that services keep working when they call each other over the network or hand work off through queues and workflows. Testing a monolith is mostly about logic inside one codebase, where a changed signature breaks the build. Between services the same break happens at runtime, across versions owned by different teams, so more of the effort moves to integration.
What is the difference between microservices testing and integration testing?
Integration testing is one layer inside microservices testing, not a separate practice. Microservices testing covers unit, contract, integration, end-to-end, performance, chaos and security tests together. Integration testing checks specifically that two or more real services behave correctly when they call each other, at the versions actually deployed. Contract testing sits between the two and checks API and message shapes without running the other service.
What types of tests does a microservices application need?
Seven kinds, in different amounts. Unit tests cover logic inside a service. Contract tests check API and message shapes. Integration tests run real services together. End-to-end tests drive a whole user journey. Performance tests find slow call chains, chaos tests check behavior when a dependency fails, and security tests check authorization between services. In microservices testing, the last five only mean something against real dependencies.
What is the right way to run end-to-end tests on microservices?
Keep the suite thin and point it at real services. Pick the few user journeys that carry revenue or trust, drive each through the UI or the public API with Playwright, Cypress or an API client, and run it in an isolated environment for each change instead of a shared one. Poll for asynchronous outcomes with a deadline instead of sleeping. Microservices testing done this way leaves edge cases to integration tests.
How do you test synchronous and asynchronous flows between microservices?
Test a synchronous REST or gRPC call by sending a request through the real chain of services and checking the response, the latency and the error handling. Test an asynchronous flow by publishing a real message to a real broker and asserting on what the consumer did. In microservices testing both need isolation per change: request routing for calls, and message routing or a separate topic or queue for Kafka, SQS, RabbitMQ and Pub/Sub.
How do you test microservices that use a durable workflow engine?
In two steps. First test the workflow logic with the engine's own tools: a test server that skips time, and a replay of recorded histories against new code to catch changes that would break workflows already in flight. Then run the changed workflow code against the real services its steps call. Microservices testing that stops at the first step misses the retry, replay and versioning bugs durable workflows are prone to.
Why do microservices tests pass but production still breaks?
Because the tests ran against dependencies that no longer match what runs in production. Mocks go stale as the services they imitate change, and a staging environment three deploys behind gives the same false confidence. The fix in microservices testing is to run integration tests against the current shared versions of dependencies rather than against static mocks or a copy of the system that has drifted.
How many environments do you need to test microservices safely?
Three layers, not a separate dev, QA, staging and pre-production environment apiece. You need a local or agent working copy of the one service being changed, one shared cluster holding the current versions of every other service, and a way to give each change its own isolated slice of that cluster. That is enough for microservices testing at any number of services, because one cluster serves every change at once.
Can a coding agent test its microservices change against live services before a pull request exists?
Yes, if it has somewhere to run the test. An agent works in a build-test-fix loop and needs an isolated environment with real dependencies it can create, test against, and tear down without waiting on a person. Given a CLI, an API or an MCP server that exposes those actions, agents like Claude Code and Cursor run microservices testing before a reviewer ever sees the change.
How do AI coding agents change microservices testing requirements?
They produce changes that are complete inside one service and incomplete across the services around it. An agent works in one repository, so the caller or consumer its change breaks is often in a service it never read. Microservices testing for agent-written code has to run each change against the real neighbors before review, in an isolated environment the agent creates itself, with a time-to-live so abandoned runs clean up.