Microservices Testing: Is There Room For Automation?

Microservices have been around for about fifteen years, and it looks like they are still relevant. After all, O’Reilly’s report says this simplified architecture model proved at least somewhat successful for 92% of the survey participants. So what are the essential aspects of assuring the quality of microservices, and can testing be sped up with automation?

Microservices testing strongholds

Testing regular monolithic systems differs significantly from microservices testing. The thing is, every microservice is a fully functional independent system that communicates with other microservices via an API. These specifics affect the testing process.

First of all, traditional end-to-end testing doesn’t work here as QA engineers start by testing each microservice separately. Then they check the quality of interactions between adjacent microservices, often replacing those microservices that are still in production with mocks.

Microservices are believed to be scalable, flexible, and adaptable. One of the key benefits of this architecture is that it speeds up the development, which fosters teams’ agility. Testing automation can be an additional time-saver here.

Info

Where does automation fit?

Automated testing in the field of microservices may be implemented in several testing types, such as unit, contract, performance and integration testing. Performance testing aside, let’s focus on the three remaining testing types specific to microservices.

Unit testing

This kind of testing checks the smallest testable and functional chunks of code to detect potential issues at the very start. Due to a moderate cost, ease of performance, and efficiency, unit testing makes a central point of the microservices testing cycle.

Unit tests work as efficient quality guards and cost moderators, as they allow developers to fix bugs before their effect spreads throughout the system. However, there’s one drawback: manual unit testing is rather time-intense and hence error-prone. This is what makes this testing method a candidate for automation.

Unit test automation does require some efforts on testers’ part. Nevertheless, testers have a powerful facilitator — unit testing frameworks. To get up to speed in this area, test engineers use GitHub and choose open-source solutions with an active community and recent updates deployed.

There’s yet another peculiarity here. Test coverage for such tests shouldn’t reach 100% of the code. These tests often lose relevance due to bug fixes, so if the team targets a 100% test coverage with such short-lived scripts, this may increase the testing costs. Hence, it makes sense to focus on writing test scripts for more stable points, such as those describing complex processes or business logic.

Contract testing

When it comes to microservices, a contract is a set of agreements between the interacting services — the provider and the consumer. So how to test such interactions effectively?

QA experts recommend selecting a set of detailed and well-written contracts for each microservice. These sets provide the basic idea of the communication between microservices.

However, microservices are not typically developed all at once. Hence, mocks may come in handy once again. Here is how it works: a consumer service is tuned to send requests to a mock provider. The provider checks if such requests are allowed by the contract conditions and acts accordingly — either responds as expected or sends a failure notification.

Info

Integration testing and its alternatives

Full-scale integration testing is run when all the microservices have been developed. While smooth interconnections are important for the product’s success, the number of potential service-to-service “conversations” may be unreasonably high, which may take up time and money.

This is not the only challenge microservices integration testing presents. Among other potential pitfalls are:

  • Difficulties with setting up the test environment, scaling, test maintenance, and debugging
  • Unreliable results due to complex test environment configuration

Well-aware of these peculiarities, QA professionals recommend minimizing the use of traditional integration testing and employ it for a minimal number of user journeys that clearly reflect the system’s user flows. Consumer-driven automated contract testing is the way to go for the rest of the testing scope. This type of testing verifies if a provider’s response fits the consumer service expectations.

Leveraging AI

AI application in testing became a top trend in 2020, and practitioners are not planning to scale down. According to the World Quality Report 2020-2021, 71% of the survey respondents are going to use more AI in their testing activities. So what’s in it for microservices testing?

Enhancing microservices testing with AI may speed up the process further, as it cuts the time needed for creating and maintaining the scripts. It may also improve testing accuracy and facilitate the process for distributed teams. AI technologies may also assist testers with data analysis, maintenance, and adequate data modeling, which is critical for granular solution testing.

As for the types of testing that AI may bring to a new level, they comprise unit tests and contract tests — the crucial elements of testing solutions specific to microservices.

Summing up

As development acceleration is the very essence of microservices, automation makes a perfect match for this modular technology testing. Testers can go further and enhance microservices test automation with a suitable AI solution to speed up testing and refine its accuracy. Nonetheless, this effort pays off only if the team is proficient in AI-enhanced testing. Otherwise, it may only disrupt the testing process and lead to confusion.

 

Check out all the software testing webinars and eBooks here on EuroSTARHuddle.com

About the Author

Mihail

At a1qa, Mihail is a Head of test automation and performance testing lab staffed with more than 170 QA engineers.
Find out more about @m-urbanovich

Related Content