Listen on the go!

Microservices is not a new concept. It has been in use for more than a decade now by giants such as Amazon, Google, and Facebook. When you search for something on Google, to retrieve the relevant results, Google calls out to almost 70 microservices.

So what really is a Microservice?

“Microservices” is a yet another term added to the already crowded streets of software architecture. The microservice architectural style involves developing single applications that can work together as a suite of small services, each running in its individual process and communicating with lightweight mechanisms such as an HTTP resource API. These services require bare minimum centralized management, use different data storage technologies, and can be written in different programming languages. These services, built around business capabilities, can also be deployed independently by machinery that supports fully automated deployment.

SOA vs. Microservices

The typical service oriented architecture (SOA) model usually has dependent enterprise service buses (ESBs), with microservices using faster messaging mechanisms. While SOA focuses on imperative programming, the microservices architecture uses a programming style that focuses on a responsive-actor as its base. While SOA models usually have an outsized RDBMS, microservices frequently use databases such as NoSQL or micro-SQL that can be connected to conventional databases. That said, the real difference lies in the architecture methods that are used for creating an integrated set of services.

The practices that are used for the microservices architecture have been created based on the practices followed by developers for creating software applications for large enterprise organizations. The experience of developers comes in very handy to understand what are the expectations of today’s end users, and helps create a consistent, yet dynamic experience across a wide range of devices. Cloud-based applications that are accessible, adaptable, modular, and scalable are in high demand. This has led many developers to change their approach.

Testing Microservices

A microservices architecture consists of focused, small services that together create a complete application or task. Every instance of a microservice represents a single responsibility within your application. The real advantage is that, these services are independent of one another, which makes them independently deployable and testable.

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

1. Unit Testing

The scope of unit testing is internal to the service. In terms of volume of tests, they are the largest in number. Unit tests should ideally be automated, depending on the development language and the framework within the service.

2. Contract 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. Any dependencies of the service must be stubs that allow the service to function but do not interact with any other services. This helps avoid any complicated behavior that may be caused by external calls and turn the focus on performing the tests on a single service.

A “contract” is how a service call (where a specific result or output is expected for certain inputs) is referred to by the consumer-contract testing. Every consumer must receive the same results from a service over time, even if the service changes. There should be the flexibility to add more functionality as required to the Responses later on. However, these additions must not break the service functionality. If the service is designed in this manner, it will stay robust over longer durations and the consumers will not be required to modify their code to take into account the changes made later on.

3. Integration Testing

Verification of the services that have been individually tested must be performed. This critical part of microservice architecture testing relies on the proper functioning of inter-service communications. Service calls must be made with integration to external services, including error and success cases. Integration testing thus validates that the system is working together seamlessly and that the dependencies between the services are present as expected.

4. End-To-End Testing

End-to-end testing verifies that the entire process flows work correctly, including all service and DB integration. Thorough testing of operations that affect multiple services ensures that the system works together as a whole and satisfies all requirements. Frameworks like JBehave help automate Functional testing by taking user stories and verifying that the system behaves as expected.

5. UI/Functional Testing

User interface testing is the testing of the highest order as it tests the system as an end-user would use it. Testing of this level must feel like a user trying to interact with the system. All the databases, interfaces, internal and third-party services must work together seamlessly to produce the expected results.

At Cigniti, we cover all the bases and ensure that effective testing is performed by the right set of experts. We ensure the best quality for your product and that your customers are happy. Our tool agnostic test automation frameworks ensure accelerated testing so that you get higher productivity and an enviable time to market

About the Author: Peter Anand Shah is an Assistant Manager at Cigniti Technologies. He is a part of the Enterprise Solutions Group which primarily helps convert Leads to Deals by devising the best solutions. He has an overall experience of 10+ years having taken up the roles of a Kronos Consultant and Test Manager in his past engagements. Off work, Peter is a stand-up-comedian.