VOOZH about

URL: https://thenewstack.io/the-struggle-to-test-microservices-before-merging/

⇱ The Struggle To Test Microservices Before Merging - The New Stack


TNS
SUBSCRIBE
Join our community of software engineering leaders and aspirational developers. Always stay in-the-know by getting the most important news and exclusive content delivered fresh to your inbox to learn more about at-scale software development.
REQUIRED
It seems that you've previously unsubscribed from our newsletter in the past. Click the button below to open the re-subscribe form in a new tab. When you're done, simply close that tab and continue with this form to complete your subscription.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.
Welcome and thank you for joining The New Stack community!
Please answer a few simple questions to help us deliver the news and resources you are interested in.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Great to meet you!
Tell us a bit about your job so we can cover the topics you find most relevant.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Welcome!

We’re so glad you’re here. You can expect all the best TNS content to arrive Monday through Friday to keep you on top of the news and at the top of your game.

What’s next?

Check your inbox for a confirmation email where you can adjust your preferences and even join additional groups.

Follow TNS on your favorite social media networks.

Become a TNS follower on LinkedIn.

Check out the latest featured and trending stories while you wait for your first TNS newsletter.

PREV
1 of 2
NEXT
VOXPOP
As a JavaScript developer, what non-React tools do you use most often?
Angular
0%
Astro
0%
Svelte
0%
Vue.js
0%
Other
0%
I only use React
0%
I don't use JavaScript
0%
Thanks for your opinion! Subscribe below to get the final results, published exclusively in our TNS Update newsletter:
NEW! Try Stackie AI
From clobbered drafts to real-time sync
Apr 14th 2026 10:00am, by David Moore
TypeScript 6.0 RC arrives as a bridge to a faster future
Mar 14th 2026 9:00am, by Darryl K. Taft
Mastra empowers web devs to build AI agents in TypeScript
Jan 28th 2026 11:00am, by Loraine Lawson
2024-08-21 12:48:58
The Struggle To Test Microservices Before Merging
sponsor-signadot,sponsored-post-contributed,
API Management / Software Development / Software Testing

The Struggle To Test Microservices Before Merging

A look at the types of integration testing, focusing on pre-merge tests that provide quick feedback to developers.
Aug 21st, 2024 12:48pm by Nočnica Mellifera
👁 Featued image for: The Struggle To Test Microservices Before Merging
Photo by Chris Linnett on Unsplash
Signadot sponsored this post.

It’s always a struggle to test microservices well. When you talk about testing, the fuzzy definition of testing phases comes up right away. Is a test involving all the services an integration test? Or an end-to-end test? Is a test of meeting API spec a contract test? Or a unit test? Specifically, the idea of an integration test can cover a number of things:

  • Contract testing
  • Tests using mocks
  • API integration tests

But rather than splitting hairs about what is being tested, I think a better question is “what is the purpose of integration tests?” If the purpose of integration testing is to see how our updated service interacts with the rest of our stack, then we want to run this testing before merging our code with production or pre-production environments.

Proper integration testing can help catch issues early, reducing the chances of defects reaching production. However, the approach to integration testing can vary, each with its own benefits and drawbacks.

Let’s look at the types of integration testing, focusing on pre-merge tests that provide quick feedback to developers and explore how they can be efficiently run on developer workstations and with shared environments during pull requests (PRs).

Integration Testing on Your Laptop: Drawbacks of Mocks

I got my start in the tech industry doing support for an online classroom tool. During a conversation with engineering, I asked about test coverage. The team told me they had automated tests that simulated normal update actions for a virtual classroom. “How many students are in your test case?” I asked. “Oh, a whole bunch, like 50. We wanted to make sure it could handle large classes.” I then explained that the largest virtual classroom I’d seen in the real world was about 2,000 students, and our whole UX really broke at those scales. This points out how a totally contrived testing scenario, no matter how carefully engineered, can fail to simulate real-world situations.

Integration testing using mocks does not require a full environment setup or bringing up many dependencies. With startup times near zero and a testing stack you can run on your laptop, this means very fast feedback.

Developers can create very custom test setups, seeding specific data and running precise tests. The primary benefit here is the ability to simulate specific interactions without needing a full environment.

However, maintaining mocks can be labor-intensive. Tests may focus on synthetic scenarios that might not reflect real-world conditions, making it difficult to achieve comprehensive coverage. Mocks are particularly useful for validating interactions between tightly coupled components, such as microservices and databases, but they may not be suitable for all types of integration testing.

In general, tests backed with mocks are difficult for establishing “coverage”: We can feel certain we’ve covered cases that we’ve seen before with two components, but not that we’re covering every real-world scenario.

Integration Testing Via Contract Testing

There’s some value to performing contract tests for integration testing. When services interact via HTTP and have RESTful relationships, the sending of predicted requests or responses can help ensure that services can still talk to each other after an update. But scripting a large number of requests can be quite time-consuming, and we still get into the space of simulating multiple steps of request handling, which risks having updates that pass all tests but don’t work on production.

Testing in a Real Environment

End-to-end testing is really where the rubber meets the road, and we get the most reliable tests when sending in requests that actually hit all dependencies and services to form a correct response. Integration testing at the API or frontend level using real microservice dependencies offers substantial value. These tests assess real behaviors and interactions, providing a realistic view of the system’s functionality. Typically, such tests are run post-merge in a staging or pre-production environment, often referred to as end-to-end (E2E) testing. This approach ensures comprehensive coverage and high accuracy, but by only running tests after branches are merged, the dev loop is made much longer, with developers waiting hours or days for test feedback.

What’s worse, in a microservice environment the odds are good that most significant failures are found at the stage of integration testing. We can’t have developers waiting days to get test feedback when it’s highly likely those tests will fail.

Testing in a Real Environment Before Merging

What we really want is a realistic environment that can be used by any developer, even at an early stage of working on a PR. Achieving the benefits of API and frontend-level testing pre-merge would save effort on writing and maintaining mocks while testing real system behaviors. This can be done using canary-style testing in a shared baseline environment, akin to canary rollouts but in a pre-production context. To clarify that concept: We want to try running a new version of code on a shared staging environment, where that experimental code won’t break staging for all the other development teams, the same way a canary deploy can go out, break in production and not take down the service for everyone.

Request routing can be used to run API and E2E tests on PRs in a real shared environment with all dependencies, providing early and accurate feedback. Companies like Lyft effectively use this approach to streamline their testing processes.

The implementation of a request routing solution to let “test” versions of services interact with a cluster while also not breaking or modifying flows for other developers can be super effective for your testing process, but it’s not without technical lift to implement, that’s where Signadot comes in.

Share a Single Environment Pre-merge

Signadot is a tool to let teams of any scale implement high-quality pre-merge testing with a shared staging cluster. Signadot enables teams to share and maintain a single environment while running tests on select services.

👁 A Signadot sandbox letting users experiment with a modified version of service C.

A Signadot sandbox letting users experiment with a modified version of service C

By enabling integration tests to run pre-merge, it significantly reduces the time and effort required for testing. This approach eliminates the need to duplicate environments, leading to substantial cost savings. For more details, visit Signadot.

Signadot is a Kubernetes-native platform that empowers AI coding agents to verify code at scale. Combining fast, scalable ephemeral environments with a validation framework built for complex distributed systems, Signadot ensures high-velocity code generation results in safely merged pull requests.
Learn More
The latest from Signadot
Hear more from our sponsor
TRENDING STORIES
Nočnica Mellifera (She/Her) was a developer for seven years before moving into developer relations. She specializes in containerized workloads, serverless, and public cloud engineering. Nočnica has long been an advocate for open standards, and has given talks and workshops on...
Read more from Nočnica Mellifera
Signadot sponsored this post.
SHARE THIS STORY
TRENDING STORIES
TNS owner Insight Partners is an investor in: Real.
SHARE THIS STORY
TRENDING STORIES
TNS DAILY NEWSLETTER Receive a free roundup of the most recent TNS articles in your inbox each day.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.
👁 Image
Enable cloud-native agentic workflows at scale and validate code as fast as agents can generate it.