SlideShare a Scribd company logo
Testing Java Microservices:
From Development to Production
Abraham Marin-Perez | Daniel Bryant
tl;dr
● Testing microservices brings additional challenges
● Pay special attention to integration surfaces
● Isolate services for loosely coupled tests
● Include tests that resemble production
● Make security testing a first-class citizen
Who are we?
@danielbryantuk
Tech Consultant and Writer
Product Architect at Datawire
Java Champion
Conference Tourist
@abrahammarin
Developer, Consultant, Writer
Associate of Equal Experts
Software Plumber
Types of tests
From Agile Testing, by Lisa Crispin and Janet Gregory
Challenges
● Cannot share a single environment: test locally
● Full ecosystem unsuitable for local testing
● Lack of control over third-party dependencies
Isolation
Isolating Parts
Third Party
Isolating Parts
Third Party
Testing Java Microservices: From Development to Production
Isolating Parts: No Isolation
Third Party
Isolating Parts: Unowned Components
Third Party
Test Doubles
Test Doubles
Dummy objects: passed around but never actually used.
Fake objects: working implementations not suitable for production
Stubs: provide canned answers to calls made during the test
Spies: stubs that also record some information based on how they were called.
Mocks: objects pre-programmed with expectations which form a specification of the
calls they are expected to receive.
Virtualisations: emulation of services, with expectations (not suitable for production)
Testing Java Microservices: From Development to Production
Testing Java Microservices: From Development to Production
Testing Java Microservices: From Development to Production
Testing Java Microservices: From Development to Production
Testing Java Microservices: From Development to Production
Testing Java Microservices: From Development to Production
JUnit Example
API Simulation Thoughts
● Useful when a dependency is “expensive” to
access or tricky to mock
● Facilitates error handling tests when dependency
failure modes are challenging to recreate
● Simulations can be fragile and/or complicated
Use simulations appropriately...
Sometime you need the real thing
Testing Java Microservices: From Development to Production
Isolating Parts: Service Interaction
Third Party
Focused on
service/function
Focused on
system
Contract Tests
API Contracts
APIs are service contracts
Many are producer-driven
It’s possible to design outside-in:
Consumer-Driven Contracts
Consumer-Driven Contracts
Consumer-Driven Contract Frameworks
https://docs.pact.io/ https://cloud.spring.io/spring-cloud-contract/
Consumer-Driven Contract Thoughts
● Great in low trust or low communication organisations
○ Act as a cue for a conversation
● Can be used to implement “TDD for the API”
● Resource intensive to create and maintain
https://bit.ly/2p68gBS
Components
Isolating Parts: Single Service
Third Party
Isolating Parts: Single Service
Isolating Parts: Single Service
Test
Doubles
Isolating Parts: Single Service
Isolating Parts: Single Service
+
Isolating Parts: Single Service
Fault Tolerance
Test double configured to fail
https://technology.cap-hpi.com/blog/unit-testing-what-benefits-you-can-reap/
Isolating Parts: Technicalities
Third Party
Isolating Parts: Technicalities
Test the Real Thing
Isolating Parts: Technicalities
Isolating Parts: Data
Test Data
● Low Volume
● Low Diversity
Production Data
● High Volume
● High Diversity
Isolating Parts: Data
Isolating Parts: Data
Marín
Argüelles
d’Hopital
Garçon
Castaña
Strauß
Fønss
Bård
かほる
Александр
สมชาย
Φραγκόπουλος
Isolating Parts: Data
Testing Java Microservices: From Development to Production
www.owasp.org
https://www.owasp.org/index.php/C
ategory:OWASP_Top_Ten_Project
Security: Code
Security: Dependencies
Security: Container Images
github.com/arminc/clair-scanner
Conclusion
● Testing microservices brings additional challenges
● Pay special attention to integration surfaces
● Isolate services for loosely coupled tests
● Include tests that resemble production
● Make security testing a first-class citizen
Thanks!
Some code samples:
https://github.com/orgs/continuous-delivery-in-java
(with more coming soon!)

More Related Content

PDF
Kubernetes Native Java and Eclipse MicroProfile | EclipseCon Europe 2019
PDF
Efficient DevOps Tooling with Java and GraalVM
PDF
In defense of GWT-RPC By Colin Alworth
PDF
Red Hat Java Update and Quarkus Introduction
PDF
Performance Profiling Tools and Tricks
PDF
Clean Infrastructure as Code
PDF
Meetup 2020 - Back to the Basics part 101 : IaC
PDF
Security: The Value of SBOMs
Kubernetes Native Java and Eclipse MicroProfile | EclipseCon Europe 2019
Efficient DevOps Tooling with Java and GraalVM
In defense of GWT-RPC By Colin Alworth
Red Hat Java Update and Quarkus Introduction
Performance Profiling Tools and Tricks
Clean Infrastructure as Code
Meetup 2020 - Back to the Basics part 101 : IaC
Security: The Value of SBOMs

What's hot (20)

PDF
Improving security with Istio | DevNation Tech Talk
PDF
Lightweight Virtualization with Linux Containers and Docker | YaC 2013
PDF
You Want to Kubernetes? You MUST Know Containers!
PDF
QCon SF 2017 - Microservices: Service-Oriented Development
PDF
Intro to Kubernetes & GitOps Workshop
PPTX
K8s from Zero to ~Hero~ Seasoned Beginner
PPTX
Cleaner Code Through Test-Driven Development
PPTX
Spring Boot & Spring Cloud on k8s and PCF
PDF
Docker Introduction
PDF
A Taste of Monitoring and Post Mortem Debugging with Node
PPTX
Cloud Native CI/CD with Spring Cloud Pipelines
PDF
E bpf and profilers
PDF
OpenDaylight Developers Experience 1.5: Eclipse Setup, HOT reload, future plans
PDF
Case Study: Using Qt to Develop Advanced GUIs & Advanced Visualization Software
PDF
WTF is GitOps and Why You Should Care?
PDF
How fast can you onboard a new team member with VAGRANT ?
PPTX
PDF
Containers and Kubernetes without limits
PDF
Continuous (Non)-Functional Testing of Microservices on k8s
ODP
Qt 5 - C++ and Widgets
Improving security with Istio | DevNation Tech Talk
Lightweight Virtualization with Linux Containers and Docker | YaC 2013
You Want to Kubernetes? You MUST Know Containers!
QCon SF 2017 - Microservices: Service-Oriented Development
Intro to Kubernetes & GitOps Workshop
K8s from Zero to ~Hero~ Seasoned Beginner
Cleaner Code Through Test-Driven Development
Spring Boot & Spring Cloud on k8s and PCF
Docker Introduction
A Taste of Monitoring and Post Mortem Debugging with Node
Cloud Native CI/CD with Spring Cloud Pipelines
E bpf and profilers
OpenDaylight Developers Experience 1.5: Eclipse Setup, HOT reload, future plans
Case Study: Using Qt to Develop Advanced GUIs & Advanced Visualization Software
WTF is GitOps and Why You Should Care?
How fast can you onboard a new team member with VAGRANT ?
Containers and Kubernetes without limits
Continuous (Non)-Functional Testing of Microservices on k8s
Qt 5 - C++ and Widgets
Ad

Similar to Testing Java Microservices: From Development to Production (20)

PDF
CodeOne SF 2018: "Testing Java Microservices: From Development to Production"
PPTX
Devoxx UK 2019: "Testing Java Microservices: From Development to Production
PPTX
[SC London] "Testing Microservices: from Development to Production
PPTX
deliver:Agile 2019 "Testing Microservices: From Development to Production
PDF
Tests immutable when refactoring - SegFault Unconference Cracow 2019
PDF
Introduce Test Harness for Direct To Consumer Solutions.pdf
PDF
Top 10 Katalon Alternatives_ A Comprehensive Comparison.pdf
PDF
Testing Microservices
PDF
Developer Experience to Testing
PPTX
Opticon18: Developer Night
PDF
Playwright, Cypress, or TestGrid: A Feature-by-Feature Breakdown for Test Aut...
PDF
Taking your code to production
PPT
Automated Testing v s Manual Testing.ppt
PPT
Automated Testing vs Manual Testing.ppt
PPTX
Test Strategies in Microservices
PPTX
Mobile App Quality Roadmap for DevTest Teams
PPTX
Testing strategies in microservices
PPTX
ITARC15 Workshop - Architecting a Large Software Project - Lessons Learned
PDF
Approaching ATDD/BDD
PDF
Presentation on Unit Test with Python and Pytest
CodeOne SF 2018: "Testing Java Microservices: From Development to Production"
Devoxx UK 2019: "Testing Java Microservices: From Development to Production
[SC London] "Testing Microservices: from Development to Production
deliver:Agile 2019 "Testing Microservices: From Development to Production
Tests immutable when refactoring - SegFault Unconference Cracow 2019
Introduce Test Harness for Direct To Consumer Solutions.pdf
Top 10 Katalon Alternatives_ A Comprehensive Comparison.pdf
Testing Microservices
Developer Experience to Testing
Opticon18: Developer Night
Playwright, Cypress, or TestGrid: A Feature-by-Feature Breakdown for Test Aut...
Taking your code to production
Automated Testing v s Manual Testing.ppt
Automated Testing vs Manual Testing.ppt
Test Strategies in Microservices
Mobile App Quality Roadmap for DevTest Teams
Testing strategies in microservices
ITARC15 Workshop - Architecting a Large Software Project - Lessons Learned
Approaching ATDD/BDD
Presentation on Unit Test with Python and Pytest
Ad

More from Daniel Bryant (20)

PDF
ITKonekt 2023: The Busy Platform Engineers Guide to API Gateways
PDF
CraftConf 2023 "Microservice Testing Techniques: Mocks vs Service Virtualizat...
PDF
PlatformCon 23: "The Busy Platform Engineers Guide to API Gateways"
PDF
Java Meetup 23: 'Debugging Microservices "Remocally" in Kubernetes with Telep...
PPTX
DevRelCon 2022: "Is Product Led Growth (PLG) the “DevOps” of the DevRel World"
PDF
Fall 22: "From Kubernetes to PaaS to... err, what's next"
PDF
Building Microservice Systems Without Cooking Your Laptop: Going “Remocal” wi...
PDF
KubeCrash 22: Debugging Microservices "Remocally" in Kubernetes with Telepres...
PDF
JAX London 22: Debugging Microservices "Remocally" in Kubernetes with Telepre...
PDF
CloudBuilders 2022: "The Past, Present, and Future of Cloud Native API Gateways"
PDF
KubeCon EU 2022: From Kubernetes to PaaS to Err What's Next
PDF
Devoxx UK 22: Debugging Java Microservices "Remocally" in Kubernetes with Tel...
PDF
DevXDay KubeCon NA 2021: "From Kubernetes to PaaS to Developer Control Planes"
PDF
JAX London 2021: Jumpstart Your Cloud Native Development: An Overview of Prac...
PDF
Container Days: Easy Debugging of Microservices Running on Kubernetes with Te...
PDF
Canadian CNCF: "Emissary-ingress 101: An introduction to the CNCF incubation-...
PDF
MJC 2021: "Debugging Java Microservices Running on Kubernetes with Telepresence"
PDF
LJC 4/21"Easy Debugging of Java Microservices Running on Kubernetes with Tele...
PDF
GOTOpia 2/2021 "Cloud Native Development Without the Toil: An Overview of Pra...
PPTX
HashiCorp Webinar: "Getting started with Ambassador and Consul on Kubernetes ...
ITKonekt 2023: The Busy Platform Engineers Guide to API Gateways
CraftConf 2023 "Microservice Testing Techniques: Mocks vs Service Virtualizat...
PlatformCon 23: "The Busy Platform Engineers Guide to API Gateways"
Java Meetup 23: 'Debugging Microservices "Remocally" in Kubernetes with Telep...
DevRelCon 2022: "Is Product Led Growth (PLG) the “DevOps” of the DevRel World"
Fall 22: "From Kubernetes to PaaS to... err, what's next"
Building Microservice Systems Without Cooking Your Laptop: Going “Remocal” wi...
KubeCrash 22: Debugging Microservices "Remocally" in Kubernetes with Telepres...
JAX London 22: Debugging Microservices "Remocally" in Kubernetes with Telepre...
CloudBuilders 2022: "The Past, Present, and Future of Cloud Native API Gateways"
KubeCon EU 2022: From Kubernetes to PaaS to Err What's Next
Devoxx UK 22: Debugging Java Microservices "Remocally" in Kubernetes with Tel...
DevXDay KubeCon NA 2021: "From Kubernetes to PaaS to Developer Control Planes"
JAX London 2021: Jumpstart Your Cloud Native Development: An Overview of Prac...
Container Days: Easy Debugging of Microservices Running on Kubernetes with Te...
Canadian CNCF: "Emissary-ingress 101: An introduction to the CNCF incubation-...
MJC 2021: "Debugging Java Microservices Running on Kubernetes with Telepresence"
LJC 4/21"Easy Debugging of Java Microservices Running on Kubernetes with Tele...
GOTOpia 2/2021 "Cloud Native Development Without the Toil: An Overview of Pra...
HashiCorp Webinar: "Getting started with Ambassador and Consul on Kubernetes ...

Recently uploaded (20)

PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
cuic standard and advanced reporting.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Approach and Philosophy of On baking technology
PPTX
Machine Learning_overview_presentation.pptx
PDF
Encapsulation theory and applications.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
MIND Revenue Release Quarter 2 2025 Press Release
Encapsulation_ Review paper, used for researhc scholars
Advanced methodologies resolving dimensionality complications for autism neur...
cuic standard and advanced reporting.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
MYSQL Presentation for SQL database connectivity
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
20250228 LYD VKU AI Blended-Learning.pptx
Approach and Philosophy of On baking technology
Machine Learning_overview_presentation.pptx
Encapsulation theory and applications.pdf
Chapter 3 Spatial Domain Image Processing.pdf
The AUB Centre for AI in Media Proposal.docx
A comparative analysis of optical character recognition models for extracting...
NewMind AI Weekly Chronicles - August'25-Week II
sap open course for s4hana steps from ECC to s4
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
MIND Revenue Release Quarter 2 2025 Press Release

Testing Java Microservices: From Development to Production

Editor's Notes

  • #6: The quadrants hint at a number of challenges, which for microservices is even harder because… (and then bullet points) Full ecosystem: too large, too diverse, too evolving
  • #8: to avoid gaps: expanding levels (concentric dotted lines, brittle, inefficient) chained levels (overlapping dotted lines, requires more management)
  • #9: All about trade-offs to avoid gaps: expanding levels (concentric dotted lines, brittle, inefficient) chained levels (overlapping dotted lines, requires more management)
  • #10: the whole is more than the sum of the parts, need to avoid silos
  • #11: no isolation, but closest to user experience. Necessary evil?
  • #12: biggest fully-controlled test. Need to use test doubles for unowned components Try to find better word for unowned
  • #25: to avoid gaps: expanding levels (concentric dotted lines, brittle, inefficient) chained levels (overlapping dotted lines, requires more management)
  • #33: Expect people to know this, just in case. Back-up: DBUnit, Utilis Prepare for anecdotes
  • #34: Expect people to know this, just in case. Back-up: DBUnit, Utilis Prepare for anecdotes
  • #35: Expect people to know this, just in case. Back-up: DBUnit, Utilis Prepare for anecdotes
  • #36: Expect people to know this, just in case. Back-up: DBUnit, Utilis Prepare for anecdotes
  • #37: QPid works with AMQP 1.0 ActiveMQ as well, but only later versions (5.8 or later)
  • #40: Mention Franck Pachot’s talk about how SQL varies
  • #52: “Copy” tl;dr Extra challenges when workin with microservice Test doubles, options Careful with Long-running queries, different tools for isolation,e tc. (one liner) security