SlideShare a Scribd company logo
Testing Java Microservices:
From Development to Production
Abraham Marín-Pérez | 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 am I?
@danielbryantuk
Product Architect at Datawire
Consultant, Writer
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
Devoxx UK 2019: "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)
https://martinfowler.com/articles/mocksArentStubs.html
Devoxx UK 2019: "Testing Java Microservices: From Development to Production
Devoxx UK 2019: "Testing Java Microservices: From Development to Production
Devoxx UK 2019: "Testing Java Microservices: From Development to Production
Devoxx UK 2019: "Testing Java Microservices: From Development to Production
Devoxx UK 2019: "Testing Java Microservices: From Development to Production
Devoxx UK 2019: "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
Devoxx UK 2019: "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 Contracts
https://www.baeldung.com/pact-junit-consumer-driven-contracts
Devoxx UK 2019: "Testing Java Microservices: From Development to Production
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
Isolating Parts: Data
a а
“a” “azǔ”
U+0061 U+0430
Devoxx UK 2019: "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
Wrapping Things Up
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!)
Bonus
https://medium.com/@copyconstruct/testing-microservices-the-sane-way-9bb31d158c16
Evolution of QA
Semantic Txns / Synthetic Monitoring
https://martinfowler.com/bliki/SyntheticMonitoring.html
Devoxx UK 2019: "Testing Java Microservices: From Development to Production

More Related Content

PPTX
Unit tests benefits
PDF
Testing java microservices: from development to production
PDF
CodeOne SF 2018: "Testing Java Microservices: From Development to Production"
PPTX
HDC 2010 - Creating Quality Software: A Look at Visual Studio 2010 Testing Tools
PPTX
deliver:Agile 2019 "Testing Microservices: From Development to Production
PDF
Code Review Tool Evaluation
PPTX
Code review process with JetBrains UpSource
PPT
Stc 2015 regional-round-ppt-bdd along with ci
Unit tests benefits
Testing java microservices: from development to production
CodeOne SF 2018: "Testing Java Microservices: From Development to Production"
HDC 2010 - Creating Quality Software: A Look at Visual Studio 2010 Testing Tools
deliver:Agile 2019 "Testing Microservices: From Development to Production
Code Review Tool Evaluation
Code review process with JetBrains UpSource
Stc 2015 regional-round-ppt-bdd along with ci

What's hot (20)

PPTX
Git branching policy and review comment's prefix
PPTX
Feature flag launchdarkly
PPTX
Thesis presentation over Web Development
PPTX
Automating functional testing of Flex applications.
PPTX
Gauge from an end user's perspective-fathima harris
PPTX
Cypress Test Techniques-Cucumber BDD Framework,TDD,API Tests
DOC
Gunderao _CV
PDF
Developers on test
PPTX
Behavior Driven Development
PDF
Dependency Injection with Apex
DOCX
Jenifer Breeze_Resume
DOC
Deepak_Resume_Automation
PDF
Experimental android hacking using reflection
PPT
Stc 2015 regional-round-ppt-exlopratory mobile testing with risk analysis
DOC
Amruth-Testing
PPTX
Software testing
PPT
SW Testing Fundamentals
PPTX
Cross Platform Mobile Technologies
PPTX
From One Test To Test Framework With Rapise
DOCX
Amit_3.5+exp_Software_Testing
Git branching policy and review comment's prefix
Feature flag launchdarkly
Thesis presentation over Web Development
Automating functional testing of Flex applications.
Gauge from an end user's perspective-fathima harris
Cypress Test Techniques-Cucumber BDD Framework,TDD,API Tests
Gunderao _CV
Developers on test
Behavior Driven Development
Dependency Injection with Apex
Jenifer Breeze_Resume
Deepak_Resume_Automation
Experimental android hacking using reflection
Stc 2015 regional-round-ppt-exlopratory mobile testing with risk analysis
Amruth-Testing
Software testing
SW Testing Fundamentals
Cross Platform Mobile Technologies
From One Test To Test Framework With Rapise
Amit_3.5+exp_Software_Testing
Ad

Similar to Devoxx UK 2019: "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
Integration testing.
PDF
Consumer-Driven Contract Testing
PDF
Serverless microservices: Test smarter, not harder
PPTX
Microservices Testing: Consumer Driven Contracts using PACT
PPTX
Microservices testing consumer driven contracts using pact
PPTX
vodQA(Pune) 2018 - Consumer driven contract testing using pact
PDF
Testing Microservices
PPTX
Microservices testing strategy-v2
PDF
Whitepaper : Testing Micro Services Part I & Part 2
PDF
Testing Java Microservices Using Arquillian Hoverfly Assertj Junit Selenium A...
PDF
How_to_create_modular_microservice_test_projects.pdf
PPTX
microservice testing tools and technologies
PDF
Test Strategies for Microservices with Christoph Ebeling
PDF
Pragmatic Java Test Automation
PDF
Contract Testing
PPTX
Consumer driven contracts in java world
PPTX
Contract based testing
PDF
Test Pyramid in Microservices Context
Testing Java Microservices: From Development to Production
[SC London] "Testing Microservices: from Development to Production
Integration testing.
Consumer-Driven Contract Testing
Serverless microservices: Test smarter, not harder
Microservices Testing: Consumer Driven Contracts using PACT
Microservices testing consumer driven contracts using pact
vodQA(Pune) 2018 - Consumer driven contract testing using pact
Testing Microservices
Microservices testing strategy-v2
Whitepaper : Testing Micro Services Part I & Part 2
Testing Java Microservices Using Arquillian Hoverfly Assertj Junit Selenium A...
How_to_create_modular_microservice_test_projects.pdf
microservice testing tools and technologies
Test Strategies for Microservices with Christoph Ebeling
Pragmatic Java Test Automation
Contract Testing
Consumer driven contracts in java world
Contract based testing
Test Pyramid in Microservices Context
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
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
Machine Learning_overview_presentation.pptx
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
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
Cloud computing and distributed systems.
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Encapsulation theory and applications.pdf
PDF
cuic standard and advanced reporting.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Electronic commerce courselecture one. Pdf
PPT
Teaching material agriculture food technology
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
MIND Revenue Release Quarter 2 2025 Press Release
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Machine Learning_overview_presentation.pptx
Empathic Computing: Creating Shared Understanding
Reach Out and Touch Someone: Haptics and Empathic Computing
Spectral efficient network and resource selection model in 5G networks
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Mobile App Security Testing_ A Comprehensive Guide.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
MYSQL Presentation for SQL database connectivity
Cloud computing and distributed systems.
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Encapsulation theory and applications.pdf
cuic standard and advanced reporting.pdf
Encapsulation_ Review paper, used for researhc scholars
Electronic commerce courselecture one. Pdf
Teaching material agriculture food technology
20250228 LYD VKU AI Blended-Learning.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf

Devoxx UK 2019: "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
  • #24: to avoid gaps: expanding levels (concentric dotted lines, brittle, inefficient) chained levels (overlapping dotted lines, requires more management)
  • #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: Expect people to know this, just in case. Back-up: DBUnit, Utilis Prepare for anecdotes
  • #38: Expect people to know this, just in case. Back-up: DBUnit, Utilis Prepare for anecdotes
  • #39: QPid works with AMQP 1.0 ActiveMQ as well, but only later versions (5.8 or later)
  • #42: Mention Franck Pachot’s talk about how SQL varies
  • #56: “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
  • #57: Mention signing, no questions, need to leave!!