The ultimate microservices testing reading list

Microservices provide a resilient, flexible architecture that makes teams more agile. But as with any new technology pattern, there are tradeoffs. Along with the microservices architecture comes a web of dependencies that can be difficult to track, along with a host of other new distributed computing challenges. 

This ultimate reading list provides current, leading-edge microservices testing examples and strategies from top engineers in the software industry, as well as resources on how a microservices architecture is beneficial for more controlled testing.

Testing in the Agile Era: Top Tools and Processes

Testing microservices, the sane way

If you read one article on this list, make it this one. Cindy Sridharan takes on the entire topic of testing distributed back-end services, then explores what testing can do in the pre-production stages. She also explains why builders need to embrace testing in production—essentially monitoring and exploration—to truly confirm that a system works.

Sridharan's testing pyramid for distributed systems.

Shift-right: Test microservices in the wild to tame DevOps

Joe Colantonio echoes much of Sridharan's advice—especially around testing in production—but in a shorter, more summarized article. He focuses more on end-to-end testing and consumer-driven contract testing as potentially helpful techniques.

Testing of Microservices—Spotify

André Schaffer reveals how Spotify does its microservices testing, introducing a modified vocabulary of tests and another revamp of the testing pyramid. The company's setup provides fast feedback and gives its developers confidence that their code will do what it should. It also places an emphasis on the maintainability of tests.

Spotify's testing honeycomb.

Testing Strategies in a Microservice Architecture

This article/slideshow by Toby Clemson briefly introduces microservices, then uses visuals and highlighting to help illustrate sociable versus solitary unit testing, integration test boundaries, component test boundaries, contract testing, end-to-end testing, and the benefits of testing in a microservices architecture.

"By breaking a system up into small well-defined services, additional boundaries are exposed that were previously hidden. These boundaries provide opportunities and flexibility in terms of the type and level of testing that can be employed."
Toby Clemson

Deploying And Testing Microservices

This presentation by Sam Newman, from an old FlowCon event, still provides relevant advice on microservice deployment pipelines and testing. It looks at the pros and cons of testing before versus after deployment, and it explores how many services you should release at one time.

Microservices Testing: Coupling and Cohesion (All the Way Down)

Daniel Bryant does plenty of training sessions on microservices, and he has compiled all of his testing observations, patterns, and anti-patterns into this article. He gives plenty of detailed advice—such as not letting monolithic properties creep in, or isolating intra-service tests—while also providing a bulleted summary at the beginning.

Testing Java Microservices: Not a Big Problem?

This article, also by Daniel Bryant, is a useful companion resource to his other article. It's a step-by-step instruction list illustrating his preferred method for designing, building, and testing microservices, based on his experiences helping several organizations build and deploy them. The list covers designing and building the system and services, component testing, contract testing, and end-to-end tests. It also includes tool suggestions that are specific to the Java ecosystem.

Efficiently Testing Pipelined Microservices

Suchakra Sharma shares his team's strategies for testing its microservices architecture. Here he describes his team's revised take on test-driven development (TDD) that involves staged tests, correlated observability, multi-environment testing, event-driven and cron-ed tests, and tests for accuracy and precision.

"You may have 100% unit test coverage, but simple environment configs could send you down an investigation spiral to the point that you don't even know why you started investigation in the first place!" 
Suchakra Sharma 

Microservices.io

Chris Richardson created this helpful reference site for microservices patterns, articles, and other resources. The patterns discussion includes two sections on microservice testing patterns: the service integration contract test and the service component test. Each page contains a few sentences describing the pattern's context, problem, forces, solution, examples, benefits, and drawbacks.

However, some of the pages recommend only Spring ecosystem solutions when there are clearly more tools. (Besides Spring Cloud Contract, Pact is another popular open-source tool for consumer-driven contract testing.)

Understanding Contract Testing for Microservices

Many articles gloss over contract testing, but this article by Bob Reselman focuses exclusively on the topic. Reselman, a veteran of the software industry, describes proper API specification construction, explores contract testing from the provider and consumer perspective, and explains classical TDD versus the London school of TDD in relation to contract testing for microservices.

"In the world of architectures that use microservices, the contract is the foundation upon which overall system integrity stands." 
Bob Reselman

Testing Microservices—API Days

This video presentation by Anne-Marie Charrett follows the journey of a greenfield project building the right testing strategy for its microservices architecture. The 30-minute video describes how the team used risk-based testing, swarming, and several other strategies to finally end up with the right testing approach for its software.

How Twitter Avoids the Microservices Version of “Works on My Machine”

This interview with Twitter engineer David McLaughlin, by Libby Clark, looks at the challenges Twitter ran into when testing its microservices architecture and how it addressed them. If you're having trouble with a growing dependency graph for your microservices, or if you're having to repeat testing steps for multiple availability zones, this article will give you some inspiration. It's short and high-level, but it offers up a few good insights from a company that solved some of the most difficult distributed computing challenges.

"As the number of microservices grows and the dependency graph between them grows, the confidence level you achieve from unit tests and mocks alone rapidly decreases. You end up in the microservices version of 'works on my machine.'"
David McLaughlin

Microservices Testing Strategy

Kishore Kumar shares his company's journey from a monolithic to a microservices architecture and how it improved its test suite during that transition. The testing strategy is more traditional than what you'll read in some of the previous articles, with 80% unit test code coverage for each service. (Some other articles were less convinced about the effectiveness of many unit tests.) However, Kumar agrees with other articles when it comes to the emphasis on contract testing. He used these tests to replace automated UI tests.

Writing and Testing an Event Sourcing Microservices with Kafka and Go

In this tutorial, Adam Pahlevi Baihaqi builds a microservices application in Go. The application uses Kafka to provide distributed messaging. The architectural patterns Baihaqi leverages to support a microservices architecture include command-query responsibility segregation (CQRS) and event sourcing. The testing comes early in this tutorial, since Baihaqi uses TDD and behavior-driven development (BDD) techniques to build tests before the code is written. He also sets up a continuous integration (CI) pipeline with Docker to apply tests before committing a branch. 

Awesome Microservices on GitHub

If you go to the testing section of the Awesome Microservices repository on GitHub, you'll find a few tools that are particularly useful for testing microservices. The list includes some tools for testing and mocking over the wire (WireMock, Mitmproxy), as well as a contract testing tool, Spring Cloud Contract. Pact is another popular contract testing tool.

Test your testing strategy

Do your own experiments in microservices testing to find out what works best for your software and context. In the first resource mentioned above, Cindy Sridharan admits that even her extremely detailed advice is generalized. A strategy that may seem flawed or old-fashioned in one situation may be the best solution for another. In your case, it might just fit.

These resources are a starting point to provide ideas and inspiration, but the final product is up to you. Share any new or additional resources you find on microservices testing in the comments field below.

Topics: Dev & Test