Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
TestContainers - integration testing without th...
Search
Sergei Egorov
November 16, 2016
Programming
390
1
Share
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
390
JUGBB2020: Testcontainers - Past, Present, Future
bsideup
1
240
Presentation: Reactive: Do. Or do not. There is no try.
bsideup
1
1.5k
Devoxx MA: Testcontainers deep dive
bsideup
1
180
Jokerconf 2019: Testcontainers: a year-in-review
bsideup
1
320
GeekOut 2019: Don’t be Homer Simpson with your Reactor!
bsideup
0
910
DevClub Tallinn: How to Make Your OSS Project Successful
bsideup
1
740
Pivotal Toronto 2019: Don’t be Homer Simpson with your Reactor!
bsideup
0
130
GeeCON 2019: Testcontainers: a year-in-review
bsideup
1
2.6k
Other Decks in Programming
See All in Programming
AIを導入する前にやるべきこと
negima
2
310
🦞OpenClaw works with AWS
licux
1
310
Vibe NLP for Applied NLP
inesmontani
PRO
0
530
From Formal Specification to Property Based Test
ohbarye
0
500
ついに来た!本格的なマルチクラウド時代の Google Cloud
maroon1st
0
300
When benchmarks go bad - what I learned from measuring performance wrong
hollycummins
0
150
JAWS-UG横浜 #100 祝・第100回スペシャルAWS は VPC レスの時代へ
maroon1st
0
190
Explore CoroutineScope
tomoeng11
0
120
mruby on C#: From VM Implementation to Game Scripting (RubyKaigi 2026)
hadashia
2
1.2k
GitHubCopilotCLIをはじめよう.pdf
htkym
0
290
Running Swift without an OS
kishikawakatsumi
0
860
クラウドネイティブなエンジニアに向ける Raycastの魅力と実際の活用事例
nealle
2
230
Featured
See All Featured
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
200
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
490
Site-Speed That Sticks
csswizardry
13
1.2k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
64
54k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
540
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.7k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.6k
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
140
Typedesign – Prime Four
hannesfritz
42
3k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
170
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.2k
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
110
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