Test Automation in the age of microservices – Strategies and Challenges

Microservices have been gaining traction across industries and are poised to see a stronger adoption rate in the years to come. Across sectors, many companies are aiming to achieve better enterprise agility and bring in a system more efficient than the traditional monolithic architecture. With organizations such as Amazon, Apple, Google, and Netflix scaling their microservices, the acceptance and implementation of it has grown and has compelled other players to emulate the model.

As companies look to decouple domain-level problems, API gateways see strong adoption across sectors. An API Gateway is a reverse proxy that exposes microservices as APIs. As the name implies, it acts as a “gatekeeper” between clients and microservices. Typical features of an API Gateway include the ability to authenticate requests, enforce security policies, load balance between backend services and throttle them if necessary.

While it may seem like a perfect answer to do away with monolithic systems, IT solutions need to be more modular and independent. As a result, microservices will need to co-exist with the traditional architectures and interact with the existing processes. Moreover, it will also need to be in sync with compliance imperatives for best results. To simply put, with organizations having numerous other architectural patterns already deployed, doing away with the traditional system completely may lead to a new set of challenges. In order to tame the complexities and manage the speed and flexibility of microservices, the API strategy makes for the best solution.

Test Automation in microservices and its challenges

With microservices becoming a critical part of Enterprise Architects, applications implementing them will need to be tested to ensure that the services are fully functional and are orchestrated as per business requirements.

As per the “Automation Testing Market by Technology, Testing Type, Service, Endpoint Interface and Region – Global Forecast to 2023” report published in 2018, the global automation testing market size is expected to grow from USD 8.52 billion in 2018 to USD 19.27 billion by 2023, at CAGR of 17.7% during the forecast period.

The increasing adoption of mobile devices and technologies, increasing adoption of the DevOps methodology, and transforming testing by digital transformation, are some of the factors driving the automation testing market. Moreover, manual tests are time-consuming and not full-proof. With most teams favoring automated tests in a CI-CD pipeline, the Test Strategy must use an Automation-first approach. However, microservices bring certain unique challenges to the Testing team – we articulate some of them from our real-life experiences:

Skilled resources: The primary challenge for automation testing is the lack of skilled resource. Most organizations struggle to set up QA teams that have the right skills to write automation scripts. The test automation frameworks that enterprises employ require testers with the skills to compose test scripts using various scripting languages and frameworks.

Tracing the problem: Automated tests are tools that are used to identify errors. Being able to trace back the to where the applications business logic failed is a mammoth task. using behavior-driven development could be a possible solution to refer to business-readable language that tells the business which requirement the automated script is testing.

Scaling test environments: QA teams usually don’t keep into consideration, the possibility of scalability issues while introducing test automation. The challenge arises when the need to rapidly make provision for the differing test environments that automated testing requires, scale them up, run the tests, tear them down, and do it all again just as fast if you’re not testing in the cloud. On premises, teams typically have a limited number of environments they can use, which means fewer tests they can deploy at any given time. As a result, testing takes much longer.

Too many UI tests: CSS and XPath locations in the UI change often. If QA teams target attributes like these in automated tests, it can lead to false positives and continued maintenance when the changes weaken or break the tests. Hence, the bottom-up strategy is vital that demands a unit level testing of APIs, which makes the testing more consistent.

Lack of transparency: Test automation can lack visibility when different teams are using different, disconnected automation strategies. For teams that work remotely, using different test automation frameworks, getting insights on the total testing quality can become challenging.

Adapting to the culture shifting: Adopting test automation requires a culture shift, an evolution of behavior and thinking. Often, team members and stakeholders look at throwing tools at a problem, which doesn’t fix the underlying mindset.

Strategies for successful test automation

These were just a list of some challenges that come in the way of a successful test automation of microservices. But to be able to overcome the challenges and to ensure that the results meet expectation, the most recommended is Mike Cohn’s Testing Pyramid, which takes a bottom-up approach for a quantitative analysis of how much automation effort is required at each stage of the testing lifecycle.

GU TESTS 2@2x-8

Let’s look at some approaches for how to approach automated testing.

Unit Testing: This is an internal testing service and is the largest in number and size. It is also the fastest and cheapest to automate.

Component Testing: Contract testing should treat each service as a black box and all the services must be called independently and their responses must be verified. When assured of the results, the longevity of the accuracy increases, also making way for seamless new additions to the existing systems.

Integration Testing: It is a must to perform verification of all independently tested services. Service calls must be made with integration to external services, including error and success cases. Integration testing ensures that the system is working seamlessly and that the dependencies between the services are as expected.

End-To-End Testing/API Testing: As the name suggests, end-to-end testing verifies that the entire process flows work correctly, including all service and database integration.

Additionally, there are several non-functional tests that requires equal attention. While functional testing helps in ensuring smooth performance of all the major functions, nonfunctional testing helps in assuring the reliability and security of the application.

Performance Testing: This not only evaluates the performance of the software, but it also ensures that the response time aligns with the desired time. Performance testing is carried out as a part of integration testing as well.

Load Testing: Load testing is carried out to check whether the system can sustain the pressure or load of many users accessing the application at a time. The production load is replicated in the test environment to get the accurate results by load testing.

Stress Testing: Stress testing is conducted to push the application beyond its capabilities to observe how it reacts. Contrary to load testing where maximum capacity of load is generated, stress testing is conducted where the load which is generated is more than the application can manage.

Improvement in software architecture has led to fundamental changes in the way applications are designed and tested. Teams working on testing applications need to constantly educate themselves and stay informed on the latest tools and strategies. Here are the most popular test automation tools that teams across organizations are using to get best results.

Hoverfly: Simulate API latency and failures.

Vagrant: Build and maintain portable virtual software development environments.

Pact: Frameworks consumer-driven contracts testing.

Apiary: An API documentation tool.

API Blueprint: Design and prototype APIs.

Swagger: Design and prototype APIs.

While there is a gamut of tools to choose from, there is no single-stop solution for automated testing. Testers must evaluate all the available options to make sure that the tool in consideration meets all the criteria for testing. Microservices are the next big thing in the IT solutions’ market but to be able to adopt the technology and implement the changes is more challenging than it appears to the naked eye. A skilled team equipped with the right tools is critical to ensure that a complex system architecture built on microservices can deliver the functionality, scalability and performance that business needs.

Leave a Reply

Your email address will not be published.