SlideShare a Scribd company logo
Streamline Integration
Testing with
Testcontainers
—
Andrew Guibert
Software Engineer
IBM
@andrew_guibert
Why do we write
automated tests?
EclipseCon EU 2019 | © 2019 IBM Corporation 2@andrew_guibert
Why do we write
automated tests?
To have confidence
that our application
works the way we want
it to.
EclipseCon EU 2019 | © 2019 IBM Corporation 3@andrew_guibert
What type of testing
gives us the most
confidence?
EclipseCon EU 2019 | © 2019 IBM Corporation 4
Source: If applicable, describe source origin
System/UI
Testing
Unit Testing
Integration Testing
@andrew_guibert
EclipseCon EU 2019 | © 2019 IBM Corporation 5
Which type of tests
contribute more to
your confidence in
your automated tests?
Unit/Mock tests
24%
Integration (i.e. "live server") tests
76%
@andrew_guibert
4/4 Unit Tests Passing
Faucet turns on
Faucet turns off
Drain works
Sink does not
overflow
© 2019 IBM Corporation
EclipseCon EU 2019 | © 2019 IBM Corporation
@andrew_guibert
What we have
time to do
EclipseCon EU 2019 | © 2019 IBM Corporation 7
Source: If applicable, describe source origin
Unit Testing
Integration
Testing
Manual testing if I remember
and am not swamped
@andrew_guibert
The dilemma of testing
Confidence
Time given
© 2019 IBM Corporation
EclipseCon EU 2019 | © 2019 IBM Corporation
@andrew_guibert
The dilemma of testing
Confidence
Time given
Confidence
level in tests
© 2019 IBM Corporation
EclipseCon EU 2019 | © 2019 IBM Corporation
@andrew_guibert
The dilemma of testing
Confidence
Time given
Confidence
level in tests
EclipseCon EU 2019 | © 2019 IBM Corporation
@andrew_guibert
MicroShed Testing
The Twelve-Factor App
EclipseCon EU 2019 | © 2019 IBM Corporation 12
VII. Port Binding
VIII.Concurrency
IX. Disposability
X. Dev-Prod Parity
XI. Logs
XII. Admin Processes
I. Codebase
II. Dependencies
III. Config
IV. Backing Services
V. Build, Release, Run
VI. Stateless Processes
@andrew_guibert
The Twelve-Factor App
EclipseCon EU 2019 | © 2019 IBM Corporation 13
VII. Port Binding
VIII.Concurrency
IX. Disposability
X. Dev-Prod Parity
XI. Logs
XII. Admin Processes
I. Codebase
II. Dependencies
III. Config
IV. Backing Services
V. Build, Release, Run
VI. Stateless Processes
@andrew_guibert
Dev-Prod Parity
EclipseCon EU 2019 | © 2019 IBM Corporation 14
Keep development, staging, and production
as similar as possible
Comprised of three common issues:
– The time gap
– The personnel gap
– The tools gap
@andrew_guibert
“The twelve-factor developer resists the urge
to use different backing services between
development and production, even when adapters
theoretically abstract away any differences in
backing services.”
EclipseCon EU 2019 | © 2019 IBM Corporation 15
Dev-Prod Parity
@andrew_guibert
It works
on my
machine.
EclipseCon EU 2019 | © 2019 IBM Corporation 16
@andrew_guibert
Can you spot what’s wrong here?
EclipseCon EU 2019 | © 2019 IBM Corporation
@andrew_guibert
Can you spot what’s wrong here?
EclipseCon EU 2019 | © 2019 IBM Corporation @andrew_guibert
Testing with databases
EclipseCon EU 2019 | © 2019 IBM Corporation
@andrew_guibert
EclipseCon EU 2019 | © 2019 IBM Corporation 20
Why do we do this?
• Easy to set up
• Faster than the real thing
• Been doing it this way for >10 years
@andrew_guibert
EclipseCon EU 2019 | © 2019 IBM Corporation 21
Containers
• Combines everything needed to
run a service into a single unit
• Standard way to manage
• Lightweight and disposable
• Typically configured via env
@andrew_guibert
MicroShed Testing
What it looks like
EclipseCon EU 2019 | © 2019 IBM Corporation
@andrew_guibert
Using Testcontainers
EclipseCon EU 2019 | © 2019 IBM Corporation 24
• Databases
• Messaging Brokers
• External Services
• Anything in a container
@andrew_guibert
Taking things a step further
EclipseCon EU 2019 | © 2019 IBM Corporation
@andrew_guibert
Motivation
Devs lack confidence in their
tests because…
• Tests do not reflect prod
• Writing tests takes too long
• Setup is too complex
11
11
10
7
18
9
0 10 20
WRITING TESTS IS TOO
COMPLICATED OR TIME…
OUR APP IS TOO BIG/COMPLEX
TO TEST
RUNNING THE TESTS WE HAVE
TAKES TOO LONG
DEBUGGING A TEST THAT FAILS
TAKES TOO LONG
THE TESTS WE HAVE DO NOT
ACCURATELY REPRESENT HOW…
SETTING UP OR CONFIGURING
TESTS IS TOO COMPLICATED
What factors are limiting the confidence in
your automated tests?
EclipseCon EU 2019 | © 2019 IBM Corporation
@andrew_guibert
1) Easy to set up 2) Works with
• Java EE
• Jakarta EE
• MicroProfile
3) Provide true-to-
production tests
MicroShed Testing
EclipseCon EU 2019 | © 2019 IBM Corporation 27
@andrew_guibert
MicroShed Testing
Test client JVM Docker network *
App container
App container
App containerOther container
resources
(e.g. DB)
User test code
MicroShed Testing
Testcontainers
docker-java
Convenience
libs
(e.g. REST client)
controls
* May be on different machine from test client
Test request/responses
@andrew_guibert
Example Application
EclipseCon EU 2019 | © 2019 IBM Corporation
@andrew_guibert
What it looks like
EclipseCon EU 2019 | © 2019 IBM Corporation
@andrew_guibert
Automatically
discover, build, and
start services
EclipseCon EU 2019 | © 2019 IBM Corporation 31
a) Provide container label
b) Locate Dockerfile
c) Use default image
@andrew_guibert
Wait for app container
to be ready
EclipseCon EU 2019 | © 2019 IBM Corporation 32
• Defaults to app context root
• Can use MP Health 2.0
readiness check
• Can supply path manually
@andrew_guibert
Inject REST client
EclipseCon EU 2019 | © 2019 IBM Corporation 33
• Can re-use class from app
• Can define own client
• Automatically configured
for app container
@andrew_guibert
Drive requests on
running app container
EclipseCon EU 2019 | © 2019 IBM Corporation 34
• Real HTTP requests
• Parameters and return values
converted with JSON-B
• JWT tokens applied
automatically
@andrew_guibert
Where to learn more
EclipseCon EU 2019 | © 2019 IBM Corporation 35
Testcontainers
– testcontainers.org
– github.com/testcontainers/testcontai
ners-java
MicroShed
– microshed.org/microshed-testing/
– github.com/MicroShed/microshed-
testing
Demo Used
– github.com/aguibert/oc1-demo
Andrew Guibert
@andrew_guibert
@aguibert
@andrew_guibert
36

More Related Content

Similar to MicroShed Testing (20)

PDF
IBM Cloud Private and IBM Power Systems: Overview and Real-World Scenarios
Joe Cropper
 
PDF
So you want to provision a test environment...
DevOps.com
 
PPTX
Kubernetes - 7 lessons learned from 7 data centers in 7 months
Michael Tougeron
 
PPTX
AI in Test Automation
Inflectra
 
PPTX
Kubernetes for Developers - 7 lessons learned from 7 data centers in 7 months...
Michael Tougeron
 
PDF
IBM Bluemix saves the game
gjuljo
 
PDF
Adopting DevOps in a Hybrid Cloud Featuring UrbanCode Deploy with Bluemix
IBM UrbanCode Products
 
PDF
Continuous Deployment for Deep Learning
Databricks
 
PDF
Ibm business partner connect 2015 long fong yee v1 (read-only)
Fong Yee Long
 
PDF
Ensure the integration of Microservices with Consumer Driven Contracts
Ingo Griebsch
 
PDF
Enterprise Cloud with IBM & Chef (ChefConf 2013)
Michael Elder
 
PDF
IBM Enterprise Social Solutions on Bluemix (XPages and Connections)
Niklas Heidloff
 
PPTX
IBM Bluemix by Alexis Patola | DevCon Summit 2015 #GoOpenSourcePH
DEVCON
 
PPTX
IBM Bluemix by Alexis Pantola, Ph.D | DevCon Summit 2015 #GoOpenSourcePH
DEVCON
 
PPT
How to Build a DevOps Toolchain
IBM UrbanCode Products
 
PDF
Understanding DevOps
InnoTech
 
PDF
IBM Bluemix on the go - Giulio Santoli (Mobility Hackathon)
gjuljo
 
PDF
IBM Bluemix Workshop version 3
Nguyen Tai Dzung
 
PDF
IBM BlueMix Presentation - Paris Meetup 17th Sept. 2014
IBM France Lab
 
PDF
2019 ibm io t exchange - meeting safety-related software audits
M Kevin McHugh
 
IBM Cloud Private and IBM Power Systems: Overview and Real-World Scenarios
Joe Cropper
 
So you want to provision a test environment...
DevOps.com
 
Kubernetes - 7 lessons learned from 7 data centers in 7 months
Michael Tougeron
 
AI in Test Automation
Inflectra
 
Kubernetes for Developers - 7 lessons learned from 7 data centers in 7 months...
Michael Tougeron
 
IBM Bluemix saves the game
gjuljo
 
Adopting DevOps in a Hybrid Cloud Featuring UrbanCode Deploy with Bluemix
IBM UrbanCode Products
 
Continuous Deployment for Deep Learning
Databricks
 
Ibm business partner connect 2015 long fong yee v1 (read-only)
Fong Yee Long
 
Ensure the integration of Microservices with Consumer Driven Contracts
Ingo Griebsch
 
Enterprise Cloud with IBM & Chef (ChefConf 2013)
Michael Elder
 
IBM Enterprise Social Solutions on Bluemix (XPages and Connections)
Niklas Heidloff
 
IBM Bluemix by Alexis Patola | DevCon Summit 2015 #GoOpenSourcePH
DEVCON
 
IBM Bluemix by Alexis Pantola, Ph.D | DevCon Summit 2015 #GoOpenSourcePH
DEVCON
 
How to Build a DevOps Toolchain
IBM UrbanCode Products
 
Understanding DevOps
InnoTech
 
IBM Bluemix on the go - Giulio Santoli (Mobility Hackathon)
gjuljo
 
IBM Bluemix Workshop version 3
Nguyen Tai Dzung
 
IBM BlueMix Presentation - Paris Meetup 17th Sept. 2014
IBM France Lab
 
2019 ibm io t exchange - meeting safety-related software audits
M Kevin McHugh
 

Recently uploaded (20)

PDF
Code Once; Run Everywhere - A Beginner’s Journey with React Native
Hasitha Walpola
 
PDF
Laboratory Workflows Digitalized and live in 90 days with Scifeon´s SAPPA P...
info969686
 
PDF
Cloud computing Lec 02 - virtualization.pdf
asokawennawatte
 
PPTX
Avast Premium Security crack 25.5.6162 + License Key 2025
HyperPc soft
 
PDF
Difference Between Kubernetes and Docker .pdf
Kindlebit Solutions
 
PDF
Writing Maintainable Playwright Tests with Ease
Shubham Joshi
 
PPTX
Quality on Autopilot: Scaling Testing in Uyuni
Oscar Barrios Torrero
 
PDF
Building scalbale cloud native apps with .NET 8
GillesMathieu10
 
PPTX
CONCEPT OF PROGRAMMING in language .pptx
tamim41
 
PDF
Automated Test Case Repair Using Language Models
Lionel Briand
 
PDF
The Rise of Sustainable Mobile App Solutions by New York Development Firms
ostechnologies16
 
PDF
Alur Perkembangan Software dan Jaringan Komputer
ssuser754303
 
PPTX
B2C EXTRANET | EXTRANET WEBSITE | EXTRANET INTEGRATION
philipnathen82
 
PDF
LPS25 - Operationalizing MLOps in GEP - Terradue.pdf
terradue
 
PDF
What Is an Internal Quality Audit and Why It Matters for Your QMS
BizPortals365
 
PPTX
Automatic_Iperf_Log_Result_Excel_visual_v2.pptx
Chen-Chih Lee
 
PPTX
ManageIQ - Sprint 264 Review - Slide Deck
ManageIQ
 
PDF
>Nitro Pro Crack 14.36.1.0 + Keygen Free Download [Latest]
utfefguu
 
PDF
AWS Consulting Services: Empowering Digital Transformation with Nlineaxis
Nlineaxis IT Solutions Pvt Ltd
 
PPTX
IDM Crack with Internet Download Manager 6.42 [Latest 2025]
HyperPc soft
 
Code Once; Run Everywhere - A Beginner’s Journey with React Native
Hasitha Walpola
 
Laboratory Workflows Digitalized and live in 90 days with Scifeon´s SAPPA P...
info969686
 
Cloud computing Lec 02 - virtualization.pdf
asokawennawatte
 
Avast Premium Security crack 25.5.6162 + License Key 2025
HyperPc soft
 
Difference Between Kubernetes and Docker .pdf
Kindlebit Solutions
 
Writing Maintainable Playwright Tests with Ease
Shubham Joshi
 
Quality on Autopilot: Scaling Testing in Uyuni
Oscar Barrios Torrero
 
Building scalbale cloud native apps with .NET 8
GillesMathieu10
 
CONCEPT OF PROGRAMMING in language .pptx
tamim41
 
Automated Test Case Repair Using Language Models
Lionel Briand
 
The Rise of Sustainable Mobile App Solutions by New York Development Firms
ostechnologies16
 
Alur Perkembangan Software dan Jaringan Komputer
ssuser754303
 
B2C EXTRANET | EXTRANET WEBSITE | EXTRANET INTEGRATION
philipnathen82
 
LPS25 - Operationalizing MLOps in GEP - Terradue.pdf
terradue
 
What Is an Internal Quality Audit and Why It Matters for Your QMS
BizPortals365
 
Automatic_Iperf_Log_Result_Excel_visual_v2.pptx
Chen-Chih Lee
 
ManageIQ - Sprint 264 Review - Slide Deck
ManageIQ
 
>Nitro Pro Crack 14.36.1.0 + Keygen Free Download [Latest]
utfefguu
 
AWS Consulting Services: Empowering Digital Transformation with Nlineaxis
Nlineaxis IT Solutions Pvt Ltd
 
IDM Crack with Internet Download Manager 6.42 [Latest 2025]
HyperPc soft
 
Ad

MicroShed Testing

  • 1. Streamline Integration Testing with Testcontainers — Andrew Guibert Software Engineer IBM @andrew_guibert
  • 2. Why do we write automated tests? EclipseCon EU 2019 | © 2019 IBM Corporation 2@andrew_guibert
  • 3. Why do we write automated tests? To have confidence that our application works the way we want it to. EclipseCon EU 2019 | © 2019 IBM Corporation 3@andrew_guibert
  • 4. What type of testing gives us the most confidence? EclipseCon EU 2019 | © 2019 IBM Corporation 4 Source: If applicable, describe source origin System/UI Testing Unit Testing Integration Testing @andrew_guibert
  • 5. EclipseCon EU 2019 | © 2019 IBM Corporation 5 Which type of tests contribute more to your confidence in your automated tests? Unit/Mock tests 24% Integration (i.e. "live server") tests 76% @andrew_guibert
  • 6. 4/4 Unit Tests Passing Faucet turns on Faucet turns off Drain works Sink does not overflow © 2019 IBM Corporation EclipseCon EU 2019 | © 2019 IBM Corporation @andrew_guibert
  • 7. What we have time to do EclipseCon EU 2019 | © 2019 IBM Corporation 7 Source: If applicable, describe source origin Unit Testing Integration Testing Manual testing if I remember and am not swamped @andrew_guibert
  • 8. The dilemma of testing Confidence Time given © 2019 IBM Corporation EclipseCon EU 2019 | © 2019 IBM Corporation @andrew_guibert
  • 9. The dilemma of testing Confidence Time given Confidence level in tests © 2019 IBM Corporation EclipseCon EU 2019 | © 2019 IBM Corporation @andrew_guibert
  • 10. The dilemma of testing Confidence Time given Confidence level in tests EclipseCon EU 2019 | © 2019 IBM Corporation @andrew_guibert
  • 12. The Twelve-Factor App EclipseCon EU 2019 | © 2019 IBM Corporation 12 VII. Port Binding VIII.Concurrency IX. Disposability X. Dev-Prod Parity XI. Logs XII. Admin Processes I. Codebase II. Dependencies III. Config IV. Backing Services V. Build, Release, Run VI. Stateless Processes @andrew_guibert
  • 13. The Twelve-Factor App EclipseCon EU 2019 | © 2019 IBM Corporation 13 VII. Port Binding VIII.Concurrency IX. Disposability X. Dev-Prod Parity XI. Logs XII. Admin Processes I. Codebase II. Dependencies III. Config IV. Backing Services V. Build, Release, Run VI. Stateless Processes @andrew_guibert
  • 14. Dev-Prod Parity EclipseCon EU 2019 | © 2019 IBM Corporation 14 Keep development, staging, and production as similar as possible Comprised of three common issues: – The time gap – The personnel gap – The tools gap @andrew_guibert
  • 15. “The twelve-factor developer resists the urge to use different backing services between development and production, even when adapters theoretically abstract away any differences in backing services.” EclipseCon EU 2019 | © 2019 IBM Corporation 15 Dev-Prod Parity @andrew_guibert
  • 16. It works on my machine. EclipseCon EU 2019 | © 2019 IBM Corporation 16 @andrew_guibert
  • 17. Can you spot what’s wrong here? EclipseCon EU 2019 | © 2019 IBM Corporation @andrew_guibert
  • 18. Can you spot what’s wrong here? EclipseCon EU 2019 | © 2019 IBM Corporation @andrew_guibert
  • 19. Testing with databases EclipseCon EU 2019 | © 2019 IBM Corporation @andrew_guibert
  • 20. EclipseCon EU 2019 | © 2019 IBM Corporation 20 Why do we do this? • Easy to set up • Faster than the real thing • Been doing it this way for >10 years @andrew_guibert
  • 21. EclipseCon EU 2019 | © 2019 IBM Corporation 21 Containers • Combines everything needed to run a service into a single unit • Standard way to manage • Lightweight and disposable • Typically configured via env @andrew_guibert
  • 23. What it looks like EclipseCon EU 2019 | © 2019 IBM Corporation @andrew_guibert
  • 24. Using Testcontainers EclipseCon EU 2019 | © 2019 IBM Corporation 24 • Databases • Messaging Brokers • External Services • Anything in a container @andrew_guibert
  • 25. Taking things a step further EclipseCon EU 2019 | © 2019 IBM Corporation @andrew_guibert
  • 26. Motivation Devs lack confidence in their tests because… • Tests do not reflect prod • Writing tests takes too long • Setup is too complex 11 11 10 7 18 9 0 10 20 WRITING TESTS IS TOO COMPLICATED OR TIME… OUR APP IS TOO BIG/COMPLEX TO TEST RUNNING THE TESTS WE HAVE TAKES TOO LONG DEBUGGING A TEST THAT FAILS TAKES TOO LONG THE TESTS WE HAVE DO NOT ACCURATELY REPRESENT HOW… SETTING UP OR CONFIGURING TESTS IS TOO COMPLICATED What factors are limiting the confidence in your automated tests? EclipseCon EU 2019 | © 2019 IBM Corporation @andrew_guibert
  • 27. 1) Easy to set up 2) Works with • Java EE • Jakarta EE • MicroProfile 3) Provide true-to- production tests MicroShed Testing EclipseCon EU 2019 | © 2019 IBM Corporation 27 @andrew_guibert
  • 28. MicroShed Testing Test client JVM Docker network * App container App container App containerOther container resources (e.g. DB) User test code MicroShed Testing Testcontainers docker-java Convenience libs (e.g. REST client) controls * May be on different machine from test client Test request/responses @andrew_guibert
  • 29. Example Application EclipseCon EU 2019 | © 2019 IBM Corporation @andrew_guibert
  • 30. What it looks like EclipseCon EU 2019 | © 2019 IBM Corporation @andrew_guibert
  • 31. Automatically discover, build, and start services EclipseCon EU 2019 | © 2019 IBM Corporation 31 a) Provide container label b) Locate Dockerfile c) Use default image @andrew_guibert
  • 32. Wait for app container to be ready EclipseCon EU 2019 | © 2019 IBM Corporation 32 • Defaults to app context root • Can use MP Health 2.0 readiness check • Can supply path manually @andrew_guibert
  • 33. Inject REST client EclipseCon EU 2019 | © 2019 IBM Corporation 33 • Can re-use class from app • Can define own client • Automatically configured for app container @andrew_guibert
  • 34. Drive requests on running app container EclipseCon EU 2019 | © 2019 IBM Corporation 34 • Real HTTP requests • Parameters and return values converted with JSON-B • JWT tokens applied automatically @andrew_guibert
  • 35. Where to learn more EclipseCon EU 2019 | © 2019 IBM Corporation 35 Testcontainers – testcontainers.org – github.com/testcontainers/testcontai ners-java MicroShed – microshed.org/microshed-testing/ – github.com/MicroShed/microshed- testing Demo Used – github.com/aguibert/oc1-demo Andrew Guibert @andrew_guibert @aguibert @andrew_guibert
  • 36. 36