Micro-services is an
consisting of focused,
small services that
together create a
Every instance of a microservice
represents a single responsibility
within the solution.
Key features of
• Self-contained and
• Decentralized data
• Resilient to failures
• Built around a single
• Reasonably small
Important testing scenarios
A good use case of a microservices architecture would
include the following scenarios:
1. The system is too big and complex that it becomes
difficult to manage.
2. The system is expected to handle high traffic & load
and needs to be scalable.
3. Testing between internal microservices and a third-
4. Testing for microservices which needs to be exposed
to the public domain.
Challenges in testing microservices
• Timely availability of all the services for testing.
• Complicated extraction of logs during testing and data validation.
• Identifying the scope of testing at each service level and
integration testing as each component operate on separate
services and rely on each other to cover their module and
integration with an external service.
• The availability of testing environment considering the
development strategy is agile.
• Distributed and independent nature of a microservice
architecture results in the isolation of each component of the
architecture from the rest. Thus it needs individual testing and
cover all independent services.
• Monitoring multiple log files, databases, and servers increases
the complexity of tracking down issues or verifying processes.
Microservices testing strategy
Bottom-up testing approach is an optimized solution
• Test the domain
• Tests closer to the code
• Integrate Early
• Use Mocks / Stubs
• Focus is on Test Pyramid
• Helps visualize/categorize test coverage
End to end testing
Number of tests
• Focuses on one unit (class/module) of a domain
• Verifies functionality of one unit
• White box & API testing
Unit testing helps us in the following
• Isolates the logic in places where
setting-up all the cases and covering
edge scenarios is much easier than at a
• Internal dependencies are stubbed and
• Non-functional requirements such as
end-user authentication, throttling,
monitoring, etc. are implemented at
each and every microservice level.
• Individual microservice signatures (end points) are the focus with other services that will consume the service under test.
• Test doubles (mocks) are used to simulate the behavior of consumer microservices.
• One end-point at a time is tested.
• Each service is treated as a black box.
• Tests are end-to-end within the bounds of the service.
• Assertion are on response e.g. JSON body.
Contract testing helps:
• Stub-out dependencies.
• Ensure defect identification within
• Identify defect for each service in isolation.
• Decrease complexity to test individual
• Stabilize services and providers.
• Set-up test data easily.
• Get instant feedback on individual service.
• Identify unused interface at initial level.
• An integration test verifies the communication paths and interactions between components to detect interface defects. This
is a critical part of testing a microservices for proper inter-service communication.
• Integration testing is done with data stores and external components.
Integration Testing Helps
• Inter-service communication issues.
• Provide additional coverage from unit and
contract testing for each integration point.
• Identify defsect for the following cases of
o Integration with data stores
o Gateway Integration
o Inter-service/external component
• End-to-end testing verifies that the entire process flows correctly, including all services and DB integration.
• End-to-end testing is more business facing as system is deployed and treated as a black box.
• It verifies environment setup, configuration, firewall, proxies, load balancer are correctly configured as well.
End-to-end testing helps:
• Ensure complete correctness and
health of the application.
• Reduce future risk due to coverage
• Analyze user experience while
using end-to-end workflow and
various aspects of the application.
Place and order
Verify that the
order is placed
• User interface testing is most important as it tests the system as an end-user and the end user input is random and very
• All the databases, interfaces, internal and third-party services must work together seamlessly to get the expected results.
• This is done to verify and validate the user interface.
User Interface testing helps:
• Provide perspective of end user and
therefore can identify the hidden
issue which was not identified earlier
during functional testing.
• Compatibility with multiple browsers
Mock Mastercard Mock Logistics
Tools to test
Tool Type of Testing Type of License
Free open source version and Pro Version
Rest- Assured Open source
Postman Open source
SOAtest Open source
Contract Testing Open source
Free 14-day Trial, then from $230 monthly.
NewRelic Free plan, then from $149 per month.
• Established best practices like the Test Pyramid
• Common tests across all Microservices can turn into a bottleneck, therefore
should be reduced, for example by performing more consumer-driven
• With suitable tools Stubs can be created from Microservices.
Nagarro drives technology-led business breakthroughs for industry leaders and challengers. When our
clients want to move fast and make things, they turn to us. Some of our clients include Siemens, GE,
Lufthansa, Viacom, Estēe Lauder, ASSA ABLOY, Ericsson, DHL, Mitsubishi, BMW, the City of New York, T-
Systems, SAP and Infor. Working with these clients, we continually push the boundaries of what is possible
to do through technology, and in what time frame.
Today, we are more than 5,000 experts across 20 countries. Together we form Nagarro, the global services
division of Munich-based Allgeier SE.