SlideShare a Scribd company logo
Microservice Test Strategies for
application based on Spring, K8s and
Istio
Ahmed Misbah
Microservice Test Pyramid
E2E
Out-of-Process
Component
Tests
Component Tests
Unit Tests
Microservice Test Pyramid
• As per the guide below:
https://martinfowler.com/articles/microservice-
testing/
the following tests will be implemented:
1. Unit Tests (Developers): Purpose of these tests is
to ensure that each class/method works right
independently
2. Components Tests (Developers): Purpose of
these tests is to test that all classes in the JAR
work right together independent of any external
component or service
Microservice Test Pyramid
3. Out-of-process Component Tests on Core
Microservices only (Developers): Purpose of
these tests to ensure that the microservice
works right on K8s and communicates
correctly with its DBs and other APIs
4. E2E Tests (QA): Purpose of E2E tests are to
test behavior and functionally of APIs fully
integrated
Core Microservice Component
Diagram
Istio -
Envoy -
Sidecar
Proxy
K8s - Pod
JAR – Spring Boot
K8s - Service
Spring MVC - Controller
Spring Bean - Service
Spring Data - Repository
JPA/Hibernate - ORM
Utilities
Some Data store on the
cloud
Some Driver (e.g. API
composer, another
Microservice using Envoy)
Some 3rd party API
Istio -
Envoy -
Sidecar
Proxy
K8s - Pod
JAR – Spring Boot
K8s - Service
Spring MVC -
Controller
Spring Bean - Service
Spring Data - Repository
JPA/Hibernate - ORM
Utilities
Core Microservice Integration
Some Driver (e.g. API
composer, another
Microservice through Envoy
or OSP
Istio -
Envoy -
Sidecar
Proxy
K8s - Pod
JAR – Spring Boot
K8s - Service
Spring MVC -
Controller
Spring Bean - Service
Spring Data - Repository
JPA/Hibernate - ORM
Utilities
Core Microservice Unit Tests
Some Data store on the
cloud
Some 3rd party API
Core Microservice Unit Tests
Spring MVC - Controller
Spring Bean - Service
Spring Data - Repository
JPA/Hibernate - ORM
Utilities (Mock)
Unit tests Service (Mock)
Data Store (Stub)
Unit tests
Unit tests
Repository (Mock)
Core Microservice Unit Tests
• Unit tests will run in Gitlab job
• Tests will be part of the Spring Boot application
• Junit 5 will be used
• Mockito will be used for mocking
• Controller tests will use @WebMvcTest annotation:
https://reflectoring.io/spring-boot-web-controller-test/
• Repository tests will use @DataTestJPA annotation, which
implicitly used H2 and tests ORM as well:
https://reflectoring.io/spring-boot-data-jpa-test/
• Liquibase will be used to create schemas at the start of
each test class
• Sprint @Sql annotation will be used to remove and insert
data before each test case:
https://www.javarticles.com/2016/02/spring-sql-annotation-
example.html
Some Data store on the
cloud
Some Driver (e.g. API
Composer, another
Microservice through
Envoy)
Some 3rd party API
Istio -
Envoy -
Sidecar
Proxy
K8s - Pod
JAR – Spring Boot
K8s - Service
Spring MVC -
Controller
Spring Bean - Service
Spring Data - Repository
JPA/Hibernate - ORM
Utilities
Core Microservice Component Tests
Core Microservice Component Tests
Spring MVC - Controller
Spring Bean - Service
Spring Data - Repository
JPA/Hibernate - ORM
Utilities
Component tests
Data Store (Stub)
Web server (Stub)
Core Microservice Component Tests
• Component tests will run in Gitlab job
• Tests will be part of the Spring Boot
application
• Junit 5 will be used
• Tests will use @SpringBootTest annotation
• REST/SOAP APIs will be stubbed using
WireMock:
https://www.baeldung.com/introduction-to-
wiremock
Core Microservice Component Tests
• MySQL will be stubbed using H2
• Liquibase will be used to create schemas at
the start of each test class
• Sprint @Sql annotation will be used to remove
and insert data before each test case:
https://www.javarticles.com/2016/02/spring-
sql-annotation-example.html
Core Microservice Component Tests
• Any other data store will be stubbed using an
embedded version of it:
– https://www.baeldung.com/spring-embedded-
redis
– https://www.baeldung.com/spring-boot-
embedded-mongodb
• @TODO Need to check how we will provision
test data in each NoSQL store
Some Driver (e.g. API
composer, another
Microservice through
Envoy)
Istio -
Envoy -
Sidecar
Proxy
K8s - Pod
JAR – Spring Boot
K8s - Service
Spring MVC -
Controller
Spring Bean - Service
Spring Data - Repository
JPA/Hibernate - ORM
Utilities
Core Microservice Out-of-process
Component Tests
Some Data store on the
cloud
Some 3rd party API
Out-of-process Component
Tests
Istio -
Envoy -
Sidecar
Proxy
K8s - Pod
JAR – Spring Boot
K8s - Service
Spring MVC -
Controller
Spring Bean - Service
Spring Data - Repository
JPA/Hibernate - ORM
Utilities
Core Microservice Out-of-process
Component Tests
Some Data store on the
cloud
Some 3rd party API
Core Microservice Out-of-process
Component Tests
• Out-of-process Component Tests will not be
part of the Spring Boot application under test
and will be in a separate project
• There will be one project for all core
microservice out-of-process component tests
• The tests will be separated by means of
Spring/Maven profiles. Tests will cover
happy/unhappy scenarios for whole core
microservice
Core Microservice Out-of-process
Component Tests
• Before executing the out-of-process
component tests in a gitlab job, the core
microservice will be deployed to K8s cluster
• Test drivers will be written using REST Assured
or Spring REST Template
• Liquibase will not be used to create schemas
at the start of each test class, as these scripts
will be executed in each microservice when it
starts
Core Microservice Out-of-process
Component Tests
• Sprint @Sql annotation will be used to remove
and insert data before each test case:
https://www.javarticles.com/2016/02/spring-
sql-annotation-example.html
@TODO Need to check how we will provision
test data in each NoSQL store
API Composers Component Diagram
Istio -
Envoy -
Sidecar
Proxy
K8s - Pod
JAR – Spring Boot
K8s - Service
Spring MVC - Controller
Spring Bean - Service Utilities
API Gateway (Ambassador)
Core Microservices
Istio -
Envoy -
Sidecar
Proxy
K8s - Pod
JAR – Spring Boot
K8s - Service
Spring MVC -
Controller
Spring Bean - Service Utilities
API Composers Integration
API Gateway (Ambassador)
Core Microservices
Istio -
Envoy -
Sidecar
Proxy
K8s - Pod
JAR – Spring Boot
K8s - Service
Spring MVC -
Controller
Spring Bean - Service Utilities
API Composers Unit Tests
API Composers Unit Tests
Spring MVC - Controller
Spring Bean - Service Utilities (Mock)
Unit tests Service (Mock)
Unit tests
API Gateway (Ambassador)
Core Microservices
Istio -
Envoy -
Sidecar
Proxy
K8s - Pod
JAR – Spring Boot
K8s - Service
Spring MVC -
Controller
Spring Bean - Service Utilities
API Composers Component Tests
API Composers Component Tests
Spring MVC - Controller
Spring Bean - Service Utilities
Component tests
Web server (Stub)
E2E Tests
E2E Tests
API Gateway (Ambassador)
API Composer (s)
Core Microservices
K8s
Some Data store on the
cloud
Some 3rd party API
E2E Tests
• E2E tests will run as a separate Robot
Framework project in the CI/CD pipeline in
Gitlab
• There will be one project for all E2E tests
• The tests will be separated by means of
profiles. Tests will cover happy/unhappy
scenarios for an endpoint or user story
AN Microservice Code Coverage
E2E (~ 10%)
Out-of-Process
Component
Tests (~ 20%)
Component Tests (~ 50%)
Unit Tests ( ~ 100%)
Source: https://learning.oreilly.com/library/view/the-clean-
coder/9780132542913/ch08.html
Microservice Test Coverage
• Test coverage will only be a measure for Out-of-
process component tests and E2E tests
• Minimum test coverage should be based upon
acceptance criteria of user story. This will include
all/most positive and negative scenarios
• For unit and component tests, we must take care
that code coverage can be a deceiving measure of
quality of tests. Test design techniques should be
used for designing test cases.

More Related Content

What's hot (20)

PDF
Rediscovering Spring with Spring Boot(1)
Gunith Devasurendra
 
PDF
Testing Spring Boot Applications
VMware Tanzu
 
PDF
Spring Boot
Jaran Flaath
 
PPTX
Docker Sydney: 5 Patterns for App Transformation with Containers
Elton Stoneman
 
PPTX
Java springboot microservice - Accenture Technology Meetup
Accenture Hungary
 
PPTX
Spring boot
Gyanendra Yadav
 
PPTX
Spring 5
sanskriti agarwal
 
PDF
PUC SE Day 2019 - SpringBoot
Josué Neis
 
PDF
Spring Boot
HongSeong Jeon
 
PPTX
Spring boot 3g
vasya10
 
PPTX
Next stop: Spring 4
Oleg Tsal-Tsalko
 
PDF
Spring - CDI Interop
Ray Ploski
 
PPTX
Development Process Optimization Using Docker. Based on a True Story
GlobalLogic Ukraine
 
PPT
Springboot introduction
Sagar Verma
 
PDF
Introduction to Spring Framework
Rajind Ruparathna
 
ODP
Developing Microservices using Spring - Beginner's Guide
Mohanraj Thirumoorthy
 
PDF
Migrating a JSF-Based Web Application from Spring 3 to Java EE 7 and CDI
Mario-Leander Reimer
 
PPTX
Introduction to spring boot
Santosh Kumar Kar
 
PDF
Building a Spring Boot Application - Ask the Audience! (from JavaLand 2017)
🎤 Hanno Embregts 🎸
 
PDF
Spring framework 5: New Core and Reactive features
Aliaksei Zhynhiarouski
 
Rediscovering Spring with Spring Boot(1)
Gunith Devasurendra
 
Testing Spring Boot Applications
VMware Tanzu
 
Spring Boot
Jaran Flaath
 
Docker Sydney: 5 Patterns for App Transformation with Containers
Elton Stoneman
 
Java springboot microservice - Accenture Technology Meetup
Accenture Hungary
 
Spring boot
Gyanendra Yadav
 
PUC SE Day 2019 - SpringBoot
Josué Neis
 
Spring Boot
HongSeong Jeon
 
Spring boot 3g
vasya10
 
Next stop: Spring 4
Oleg Tsal-Tsalko
 
Spring - CDI Interop
Ray Ploski
 
Development Process Optimization Using Docker. Based on a True Story
GlobalLogic Ukraine
 
Springboot introduction
Sagar Verma
 
Introduction to Spring Framework
Rajind Ruparathna
 
Developing Microservices using Spring - Beginner's Guide
Mohanraj Thirumoorthy
 
Migrating a JSF-Based Web Application from Spring 3 to Java EE 7 and CDI
Mario-Leander Reimer
 
Introduction to spring boot
Santosh Kumar Kar
 
Building a Spring Boot Application - Ask the Audience! (from JavaLand 2017)
🎤 Hanno Embregts 🎸
 
Spring framework 5: New Core and Reactive features
Aliaksei Zhynhiarouski
 

Similar to Microservice test strategies for applications based on Spring, K8s and Istio (20)

PDF
Testing Java Microservices Using Arquillian Hoverfly Assertj Junit Selenium A...
mpleteang
 
PPTX
Integration testing for microservices with Spring Boot
Oleksandr Romanov
 
PDF
Pragmatic Java Test Automation
Dmitry Buzdin
 
PDF
Test Pyramid in Microservices Context
Dhaval Dalal
 
PDF
Serverless microservices: Test smarter, not harder
DiUS
 
PDF
TDD for APIs in a Microservice World (extended Version) by Michael Kuehne-Sch...
Michael Kuehne-Schlinkert
 
PPTX
Microservices workshop
vodqa-ncr
 
PDF
TDD for APIs in a Microservice World (Short Version) by Michael Kuehne-Schlin...
Michael Kuehne-Schlinkert
 
PDF
TDD for APIs in a Microservice World (Michael Kuehne Schlinkert)
Nordic APIs
 
PDF
Microservice Test Strategy (@Bonn Code Meetup)
Per Bernhardt
 
PDF
Testing your application on Google App Engine
Inphina Technologies
 
PDF
Testing Your Application On Google App Engine
IndicThreads
 
PDF
Testing with Spring: An Introduction
Sam Brannen
 
PPTX
GeeCon.cz - Integration Testing from the Trenches Rebooted
Nicolas Fränkel
 
PPTX
Konstantinos Sidiropoulos - Testing microservices a real example
PetrosPlakogiannis
 
PDF
Test Strategies for Microservices with Christoph Ebeling
Cloud Study Network
 
PPTX
Testing microservices
Konstantinos Sidiropoulos
 
PDF
Testing Microservices
Nagarro
 
PPTX
GeeCON 2012 hurdle run through ejb testing
Jakub Marchwicki
 
PDF
SpectoLabs Xebia TestWorks Conf October 2016
spectolabs
 
Testing Java Microservices Using Arquillian Hoverfly Assertj Junit Selenium A...
mpleteang
 
Integration testing for microservices with Spring Boot
Oleksandr Romanov
 
Pragmatic Java Test Automation
Dmitry Buzdin
 
Test Pyramid in Microservices Context
Dhaval Dalal
 
Serverless microservices: Test smarter, not harder
DiUS
 
TDD for APIs in a Microservice World (extended Version) by Michael Kuehne-Sch...
Michael Kuehne-Schlinkert
 
Microservices workshop
vodqa-ncr
 
TDD for APIs in a Microservice World (Short Version) by Michael Kuehne-Schlin...
Michael Kuehne-Schlinkert
 
TDD for APIs in a Microservice World (Michael Kuehne Schlinkert)
Nordic APIs
 
Microservice Test Strategy (@Bonn Code Meetup)
Per Bernhardt
 
Testing your application on Google App Engine
Inphina Technologies
 
Testing Your Application On Google App Engine
IndicThreads
 
Testing with Spring: An Introduction
Sam Brannen
 
GeeCon.cz - Integration Testing from the Trenches Rebooted
Nicolas Fränkel
 
Konstantinos Sidiropoulos - Testing microservices a real example
PetrosPlakogiannis
 
Test Strategies for Microservices with Christoph Ebeling
Cloud Study Network
 
Testing microservices
Konstantinos Sidiropoulos
 
Testing Microservices
Nagarro
 
GeeCON 2012 hurdle run through ejb testing
Jakub Marchwicki
 
SpectoLabs Xebia TestWorks Conf October 2016
spectolabs
 
Ad

More from Ahmed Misbah (20)

PDF
6+1 Technical Tips for Tech Startups (2023 Edition)
Ahmed Misbah
 
PDF
Migrating to Microservices Patterns and Technologies (edition 2023)
Ahmed Misbah
 
PDF
Practical Microservice Architecture (edition 2022).pdf
Ahmed Misbah
 
PDF
Istio as an enabler for migrating to microservices (edition 2022)
Ahmed Misbah
 
PDF
DevOps for absolute beginners (2022 edition)
Ahmed Misbah
 
PDF
TDD Anti-patterns (2022 edition)
Ahmed Misbah
 
PPTX
Implementing FaaS on Kubernetes using Kubeless
Ahmed Misbah
 
PDF
Istio as an Enabler for Migrating Monolithic Applications to Microservices v1.3
Ahmed Misbah
 
PDF
Introduction to TDD
Ahmed Misbah
 
PDF
Getting Started with DevOps
Ahmed Misbah
 
PDF
DevOps for absolute beginners
Ahmed Misbah
 
PPTX
Cucumber jvm best practices v3
Ahmed Misbah
 
PPTX
Welcome to the Professional World
Ahmed Misbah
 
PPTX
More topics on Java
Ahmed Misbah
 
PPTX
Career Paths for Software Professionals
Ahmed Misbah
 
PPTX
Effective User Story Writing
Ahmed Misbah
 
PPTX
AndGen+
Ahmed Misbah
 
PPTX
DDT Testing Library for Android
Ahmed Misbah
 
PPTX
Big Data for QAs
Ahmed Misbah
 
PPTX
Software Architecture
Ahmed Misbah
 
6+1 Technical Tips for Tech Startups (2023 Edition)
Ahmed Misbah
 
Migrating to Microservices Patterns and Technologies (edition 2023)
Ahmed Misbah
 
Practical Microservice Architecture (edition 2022).pdf
Ahmed Misbah
 
Istio as an enabler for migrating to microservices (edition 2022)
Ahmed Misbah
 
DevOps for absolute beginners (2022 edition)
Ahmed Misbah
 
TDD Anti-patterns (2022 edition)
Ahmed Misbah
 
Implementing FaaS on Kubernetes using Kubeless
Ahmed Misbah
 
Istio as an Enabler for Migrating Monolithic Applications to Microservices v1.3
Ahmed Misbah
 
Introduction to TDD
Ahmed Misbah
 
Getting Started with DevOps
Ahmed Misbah
 
DevOps for absolute beginners
Ahmed Misbah
 
Cucumber jvm best practices v3
Ahmed Misbah
 
Welcome to the Professional World
Ahmed Misbah
 
More topics on Java
Ahmed Misbah
 
Career Paths for Software Professionals
Ahmed Misbah
 
Effective User Story Writing
Ahmed Misbah
 
AndGen+
Ahmed Misbah
 
DDT Testing Library for Android
Ahmed Misbah
 
Big Data for QAs
Ahmed Misbah
 
Software Architecture
Ahmed Misbah
 
Ad

Recently uploaded (20)

PDF
UITP Summit Meep Pitch may 2025 MaaS Rebooted
campoamor1
 
PDF
MiniTool Power Data Recovery 8.8 With Crack New Latest 2025
bashirkhan333g
 
PDF
Is Framer the Future of AI Powered No-Code Development?
Isla Pandora
 
PPTX
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
PDF
Best Web development company in india 2025
Greenusys
 
PPTX
Library_Management_System_PPT111111.pptx
nmtnissancrm
 
PDF
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
PDF
Meet in the Middle: Solving the Low-Latency Challenge for Agentic AI
Alluxio, Inc.
 
PDF
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
PDF
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
PDF
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
PDF
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
PDF
AI Prompts Cheat Code prompt engineering
Avijit Kumar Roy
 
PPTX
iaas vs paas vs saas :choosing your cloud strategy
CloudlayaTechnology
 
PPTX
Build a Custom Agent for Agentic Testing.pptx
klpathrudu
 
PDF
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
PPTX
Prompt Like a Pro. Leveraging Salesforce Data to Power AI Workflows.pptx
Dele Amefo
 
PPTX
BB FlashBack Pro 5.61.0.4843 With Crack Free Download
cracked shares
 
PDF
intro_to_cpp_namespace_robotics_corner.pdf
MohamedSaied877003
 
PDF
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
UITP Summit Meep Pitch may 2025 MaaS Rebooted
campoamor1
 
MiniTool Power Data Recovery 8.8 With Crack New Latest 2025
bashirkhan333g
 
Is Framer the Future of AI Powered No-Code Development?
Isla Pandora
 
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
Best Web development company in india 2025
Greenusys
 
Library_Management_System_PPT111111.pptx
nmtnissancrm
 
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
Meet in the Middle: Solving the Low-Latency Challenge for Agentic AI
Alluxio, Inc.
 
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
AI Prompts Cheat Code prompt engineering
Avijit Kumar Roy
 
iaas vs paas vs saas :choosing your cloud strategy
CloudlayaTechnology
 
Build a Custom Agent for Agentic Testing.pptx
klpathrudu
 
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
Prompt Like a Pro. Leveraging Salesforce Data to Power AI Workflows.pptx
Dele Amefo
 
BB FlashBack Pro 5.61.0.4843 With Crack Free Download
cracked shares
 
intro_to_cpp_namespace_robotics_corner.pdf
MohamedSaied877003
 
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 

Microservice test strategies for applications based on Spring, K8s and Istio

  • 1. Microservice Test Strategies for application based on Spring, K8s and Istio Ahmed Misbah
  • 3. Microservice Test Pyramid • As per the guide below: https://martinfowler.com/articles/microservice- testing/ the following tests will be implemented: 1. Unit Tests (Developers): Purpose of these tests is to ensure that each class/method works right independently 2. Components Tests (Developers): Purpose of these tests is to test that all classes in the JAR work right together independent of any external component or service
  • 4. Microservice Test Pyramid 3. Out-of-process Component Tests on Core Microservices only (Developers): Purpose of these tests to ensure that the microservice works right on K8s and communicates correctly with its DBs and other APIs 4. E2E Tests (QA): Purpose of E2E tests are to test behavior and functionally of APIs fully integrated
  • 5. Core Microservice Component Diagram Istio - Envoy - Sidecar Proxy K8s - Pod JAR – Spring Boot K8s - Service Spring MVC - Controller Spring Bean - Service Spring Data - Repository JPA/Hibernate - ORM Utilities
  • 6. Some Data store on the cloud Some Driver (e.g. API composer, another Microservice using Envoy) Some 3rd party API Istio - Envoy - Sidecar Proxy K8s - Pod JAR – Spring Boot K8s - Service Spring MVC - Controller Spring Bean - Service Spring Data - Repository JPA/Hibernate - ORM Utilities Core Microservice Integration
  • 7. Some Driver (e.g. API composer, another Microservice through Envoy or OSP Istio - Envoy - Sidecar Proxy K8s - Pod JAR – Spring Boot K8s - Service Spring MVC - Controller Spring Bean - Service Spring Data - Repository JPA/Hibernate - ORM Utilities Core Microservice Unit Tests Some Data store on the cloud Some 3rd party API
  • 8. Core Microservice Unit Tests Spring MVC - Controller Spring Bean - Service Spring Data - Repository JPA/Hibernate - ORM Utilities (Mock) Unit tests Service (Mock) Data Store (Stub) Unit tests Unit tests Repository (Mock)
  • 9. Core Microservice Unit Tests • Unit tests will run in Gitlab job • Tests will be part of the Spring Boot application • Junit 5 will be used • Mockito will be used for mocking • Controller tests will use @WebMvcTest annotation: https://reflectoring.io/spring-boot-web-controller-test/ • Repository tests will use @DataTestJPA annotation, which implicitly used H2 and tests ORM as well: https://reflectoring.io/spring-boot-data-jpa-test/ • Liquibase will be used to create schemas at the start of each test class • Sprint @Sql annotation will be used to remove and insert data before each test case: https://www.javarticles.com/2016/02/spring-sql-annotation- example.html
  • 10. Some Data store on the cloud Some Driver (e.g. API Composer, another Microservice through Envoy) Some 3rd party API Istio - Envoy - Sidecar Proxy K8s - Pod JAR – Spring Boot K8s - Service Spring MVC - Controller Spring Bean - Service Spring Data - Repository JPA/Hibernate - ORM Utilities Core Microservice Component Tests
  • 11. Core Microservice Component Tests Spring MVC - Controller Spring Bean - Service Spring Data - Repository JPA/Hibernate - ORM Utilities Component tests Data Store (Stub) Web server (Stub)
  • 12. Core Microservice Component Tests • Component tests will run in Gitlab job • Tests will be part of the Spring Boot application • Junit 5 will be used • Tests will use @SpringBootTest annotation • REST/SOAP APIs will be stubbed using WireMock: https://www.baeldung.com/introduction-to- wiremock
  • 13. Core Microservice Component Tests • MySQL will be stubbed using H2 • Liquibase will be used to create schemas at the start of each test class • Sprint @Sql annotation will be used to remove and insert data before each test case: https://www.javarticles.com/2016/02/spring- sql-annotation-example.html
  • 14. Core Microservice Component Tests • Any other data store will be stubbed using an embedded version of it: – https://www.baeldung.com/spring-embedded- redis – https://www.baeldung.com/spring-boot- embedded-mongodb • @TODO Need to check how we will provision test data in each NoSQL store
  • 15. Some Driver (e.g. API composer, another Microservice through Envoy) Istio - Envoy - Sidecar Proxy K8s - Pod JAR – Spring Boot K8s - Service Spring MVC - Controller Spring Bean - Service Spring Data - Repository JPA/Hibernate - ORM Utilities Core Microservice Out-of-process Component Tests Some Data store on the cloud Some 3rd party API
  • 16. Out-of-process Component Tests Istio - Envoy - Sidecar Proxy K8s - Pod JAR – Spring Boot K8s - Service Spring MVC - Controller Spring Bean - Service Spring Data - Repository JPA/Hibernate - ORM Utilities Core Microservice Out-of-process Component Tests Some Data store on the cloud Some 3rd party API
  • 17. Core Microservice Out-of-process Component Tests • Out-of-process Component Tests will not be part of the Spring Boot application under test and will be in a separate project • There will be one project for all core microservice out-of-process component tests • The tests will be separated by means of Spring/Maven profiles. Tests will cover happy/unhappy scenarios for whole core microservice
  • 18. Core Microservice Out-of-process Component Tests • Before executing the out-of-process component tests in a gitlab job, the core microservice will be deployed to K8s cluster • Test drivers will be written using REST Assured or Spring REST Template • Liquibase will not be used to create schemas at the start of each test class, as these scripts will be executed in each microservice when it starts
  • 19. Core Microservice Out-of-process Component Tests • Sprint @Sql annotation will be used to remove and insert data before each test case: https://www.javarticles.com/2016/02/spring- sql-annotation-example.html @TODO Need to check how we will provision test data in each NoSQL store
  • 20. API Composers Component Diagram Istio - Envoy - Sidecar Proxy K8s - Pod JAR – Spring Boot K8s - Service Spring MVC - Controller Spring Bean - Service Utilities
  • 21. API Gateway (Ambassador) Core Microservices Istio - Envoy - Sidecar Proxy K8s - Pod JAR – Spring Boot K8s - Service Spring MVC - Controller Spring Bean - Service Utilities API Composers Integration
  • 22. API Gateway (Ambassador) Core Microservices Istio - Envoy - Sidecar Proxy K8s - Pod JAR – Spring Boot K8s - Service Spring MVC - Controller Spring Bean - Service Utilities API Composers Unit Tests
  • 23. API Composers Unit Tests Spring MVC - Controller Spring Bean - Service Utilities (Mock) Unit tests Service (Mock) Unit tests
  • 24. API Gateway (Ambassador) Core Microservices Istio - Envoy - Sidecar Proxy K8s - Pod JAR – Spring Boot K8s - Service Spring MVC - Controller Spring Bean - Service Utilities API Composers Component Tests
  • 25. API Composers Component Tests Spring MVC - Controller Spring Bean - Service Utilities Component tests Web server (Stub)
  • 26. E2E Tests E2E Tests API Gateway (Ambassador) API Composer (s) Core Microservices K8s Some Data store on the cloud Some 3rd party API
  • 27. E2E Tests • E2E tests will run as a separate Robot Framework project in the CI/CD pipeline in Gitlab • There will be one project for all E2E tests • The tests will be separated by means of profiles. Tests will cover happy/unhappy scenarios for an endpoint or user story
  • 28. AN Microservice Code Coverage E2E (~ 10%) Out-of-Process Component Tests (~ 20%) Component Tests (~ 50%) Unit Tests ( ~ 100%) Source: https://learning.oreilly.com/library/view/the-clean- coder/9780132542913/ch08.html
  • 29. Microservice Test Coverage • Test coverage will only be a measure for Out-of- process component tests and E2E tests • Minimum test coverage should be based upon acceptance criteria of user story. This will include all/most positive and negative scenarios • For unit and component tests, we must take care that code coverage can be a deceiving measure of quality of tests. Test design techniques should be used for designing test cases.