Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
TestContainers - integration testing without th...
Search
Sergei Egorov
November 16, 2016
Programming
400
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
TestContainers - integration testing without the hassle
Presented @ TopConf Tallinn
Sergei Egorov
November 16, 2016
More Decks by Sergei Egorov
See All by Sergei Egorov
SnowOne 2020: Jabel – retrofitting Java Compiler by instrumenting it!
bsideup
1
420
JUGBB2020: Testcontainers - Past, Present, Future
bsideup
1
260
Presentation: Reactive: Do. Or do not. There is no try.
bsideup
1
1.5k
Devoxx MA: Testcontainers deep dive
bsideup
1
200
Jokerconf 2019: Testcontainers: a year-in-review
bsideup
1
340
GeekOut 2019: Don’t be Homer Simpson with your Reactor!
bsideup
0
950
DevClub Tallinn: How to Make Your OSS Project Successful
bsideup
1
810
Pivotal Toronto 2019: Don’t be Homer Simpson with your Reactor!
bsideup
0
160
GeeCON 2019: Testcontainers: a year-in-review
bsideup
1
2.7k
Other Decks in Programming
See All in Programming
contenteditable と日本語入力に向き合う
colorful12
0
210
クラウドエージェントは、 何がそんなに便利なのか / what makes cloud agents so useful
rkaga
2
240
残高管理から台帳サービスへの進化
artoy
1
210
Atomic Design, Enforced: Scaling Mobile Design Systems (next.app devCon / droidCon Berlin 2026)
steliosf
PRO
0
180
sbt 2.0: takeoff
eed3si9n
0
170
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
390
現場と育てるRailsモデリング 〜Spreadsheetから始めたモデル設計〜
siroemk
2
930
ChromeでローカルLLM
ryu1013
0
160
AI-Powered Domain-Driven Design
ziobrando
0
300
Zero-Tap Sign-In対応、結局何をすればいいの?
mitohato14
0
600
Apple Intelligenceとオンデバイス時代の到来
yahir0
0
110
Domain-Driven Transformation
hschwentner
2
2.3k
Featured
See All Featured
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
310
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
640
4 Signs Your Business is Dying
shpigford
187
23k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
120
120k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
18k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.5k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
4
1.2k
Navigating Weather and Climate Data
rabernat
0
560
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
580
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
530
Transcript
TestContainers Integration testing without the hassle Sergei @bsideup Egorov
Integration testing Why it matters?
Verify how your software product will behave in real-world conditions
Isolated from other system components to avoid false negatives
Real: databases, file systems, network interfaces, …
Grey box testing - we know some inner details, but
mostly use public APIs
None
Unit testing • Simulation tests are green, yay! • Everything
is mocked • DB is written by others, why should I test it?
Integration testing https://commons.wikimedia.org/wiki/File:Cd4007.jpg • Jeez, how did it passed the
Unit testing? • Is it a smoke? @#$%! YES IT IS! • Who knew that 100w soldering gun was a bit too powerful for it?
System testing https://commons.wikimedia.org/wiki/File:UART_8250_Microchip.jpg • Takes a lot of time to
solder • “Oh no, the power bus is too far away from my microchip!” • Interference between the components
Production
Integration testing Real-world, but isolated testing Spot the issues before
the real environment Can be run during the development You have to start real databases Should be cross-platform Slower than Unit testing Pros Cons
Obvious solution
None
Abstraction layer
CI friendly
Cross-platform
Docker Compose FTW! redis: image: redis ports: - "6379:6379" postgres:
image: postgres ports: - "5432:5432" elasticsearch: image: elasticsearch:5.0.0 ports: - "9200:9200"
But…
No ports randomization redis: image: redis ports: - "6379:6379" postgres:
image: postgres ports: - "5432:5432" elasticsearch: image: elasticsearch:5.0.0 ports: - "9200:9200"
Fighting with Docker environment
There is no place like
There is no place like Except Docker Machine
Can we improve that?
None
Remove the database
Remove the database
None
As simple as PostgreSQLContainer postgresql = new PostgreSQLContainer() GenericContainer
redis = new GenericContainer("redis:3") .withExposedPorts(6379)
TestContainers • https://github.com/testcontainers/testcontainers-java • OSS project by Richard North, supported
by ZeroTurnaround • Declarative Docker Java API wrapper • JUnit rules, can be used with other frameworks like TestNG, Cucumber, etc…
How it works • Wraps https://github.com/docker-java/docker-java • Docker environment discovery
• Will start docker-machine if it’s not started yet • Docker for Mac support • Containers cleanup on JVM shutdown
Use case #1: testing of microservices • REST service •
Java, Spring Boot • Redis and PostgreSQL • Calls some other micro-services
Demo
Use case #2: Docker as Selenium driver • Selenium/Selenide tests
• No need to install Chrome/Firefox/etc • CI friendly
Demo
Use case #3: Java agent testing • Test different Java
versions • Simplify I/O testing • The actual reason why ZeroTurnaround decided to use TestContainers :)
Demo