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
CodeOne SF 2018: "Testing Java Microservices: From Development to Production"
Isolating Parts: No Isolation
Third Party
Isolating Parts: No Isolation
Third Party
https://www.continuousdeliveryconsulting.com/blog/end-to-end-testing-considered-harmful/
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)
CodeOne SF 2018: "Testing Java Microservices: From Development to Production"
CodeOne SF 2018: "Testing Java Microservices: From Development to Production"
CodeOne SF 2018: "Testing Java Microservices: From Development to Production"
CodeOne SF 2018: "Testing Java Microservices: From Development to Production"
CodeOne SF 2018: "Testing Java Microservices: From Development to Production"
CodeOne SF 2018: "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
CodeOne SF 2018: "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: Technicalities
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
CodeOne SF 2018: "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!)
https://www.safaribooksonline.com/library/view/continuous-delivery-in/9781491986011/

More Related Content

PDF
Testing java microservices: from development to production
PPTX
Devoxx UK 2019: "Testing Java Microservices: From Development to Production
PDF
Android testing
PPTX
Code Review tool for personal effectiveness and waste analysis
PPTX
#1 unit testing
PDF
Code Review Tool Evaluation
PPTX
Elements of a Test Framework
PPT
Eclipse UI automation
Testing java microservices: from development to production
Devoxx UK 2019: "Testing Java Microservices: From Development to Production
Android testing
Code Review tool for personal effectiveness and waste analysis
#1 unit testing
Code Review Tool Evaluation
Elements of a Test Framework
Eclipse UI automation

What's hot (19)

PPTX
Unit tests benefits
PDF
Automation using RobotFramework for embedded device
PDF
Test automation_strategy_for_legacysystems
PDF
10 Benefits of Automated Testing
PDF
Robot framework - SAST Väst Q3
PPTX
Learning's from mobile testing
PPTX
Test automation within a scrum process
PDF
Functional Tests Automation with Robot Framework
PDF
Introduction to UI Automation Framework
PPTX
Code review process with JetBrains UpSource
PPTX
Choosing the Best Open Source Test Automation Tool for You
PDF
Introduction to Robot Framework – Exove
PPTX
Building an Automation Framework
PPT
Challenges faced in UI automation
PDF
Mastering Test Automation: How to Use Selenium Successfully
PPT
Hybrid Automation Framework Developement
PPTX
Unit Testing in Action - C#, NUnit, and Moq
PDF
Introduction to Test Automation
PDF
Win at life with unit testing
Unit tests benefits
Automation using RobotFramework for embedded device
Test automation_strategy_for_legacysystems
10 Benefits of Automated Testing
Robot framework - SAST Väst Q3
Learning's from mobile testing
Test automation within a scrum process
Functional Tests Automation with Robot Framework
Introduction to UI Automation Framework
Code review process with JetBrains UpSource
Choosing the Best Open Source Test Automation Tool for You
Introduction to Robot Framework – Exove
Building an Automation Framework
Challenges faced in UI automation
Mastering Test Automation: How to Use Selenium Successfully
Hybrid Automation Framework Developement
Unit Testing in Action - C#, NUnit, and Moq
Introduction to Test Automation
Win at life with unit testing
Ad

Similar to CodeOne SF 2018: "Testing Java Microservices: From Development to Production" (20)

PPTX
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
Developer Experience to Testing
PPTX
Testing strategies in microservices
PPTX
Mobile App Quality Roadmap for DevTest Teams
PDF
Approaching ATDD/BDD
PDF
DDD with Behat
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
PDF
Testing Microservices
PDF
Quality for developers
PDF
Presentation on Unit Test with Python and Pytest
PPTX
Automation testing
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
Developer Experience to Testing
Testing strategies in microservices
Mobile App Quality Roadmap for DevTest Teams
Approaching ATDD/BDD
DDD with Behat
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
Testing Microservices
Quality for developers
Presentation on Unit Test with Python and Pytest
Automation testing
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
Approach and Philosophy of On baking technology
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
cuic standard and advanced reporting.pdf
PPT
Teaching material agriculture food technology
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
A Presentation on Artificial Intelligence
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Empathic Computing: Creating Shared Understanding
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
Spectroscopy.pptx food analysis technology
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
Approach and Philosophy of On baking technology
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
cuic standard and advanced reporting.pdf
Teaching material agriculture food technology
Encapsulation_ Review paper, used for researhc scholars
Unlocking AI with Model Context Protocol (MCP)
NewMind AI Weekly Chronicles - August'25-Week II
Building Integrated photovoltaic BIPV_UPV.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
A Presentation on Artificial Intelligence
Network Security Unit 5.pdf for BCA BBA.
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
sap open course for s4hana steps from ECC to s4
Empathic Computing: Creating Shared Understanding
Reach Out and Touch Someone: Haptics and Empathic Computing
Spectral efficient network and resource selection model in 5G networks
Spectroscopy.pptx food analysis technology
MIND Revenue Release Quarter 2 2025 Press Release
The Rise and Fall of 3GPP – Time for a Sabbatical?
“AI and Expert System Decision Support & Business Intelligence Systems”

CodeOne SF 2018: "Testing Java Microservices: From Development to Production"