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
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
400
JUGBB2020: Testcontainers - Past, Present, Future
bsideup
1
250
Presentation: Reactive: Do. Or do not. There is no try.
bsideup
1
1.5k
Devoxx MA: Testcontainers deep dive
bsideup
1
190
Jokerconf 2019: Testcontainers: a year-in-review
bsideup
1
340
GeekOut 2019: Don’t be Homer Simpson with your Reactor!
bsideup
0
930
DevClub Tallinn: How to Make Your OSS Project Successful
bsideup
1
760
Pivotal Toronto 2019: Don’t be Homer Simpson with your Reactor!
bsideup
0
150
GeeCON 2019: Testcontainers: a year-in-review
bsideup
1
2.7k
Other Decks in Programming
See All in Programming
自作OSでスライド発表する
uyuki234
1
3.6k
TypeScript+Orvalで実現する型安全かつ堅牢でスケーラブルなマルチチャネル通知基盤 / TSKaigi Night talks ~after conference~
d0riven
0
380
ECSアプリログをFireLensでコスト削減しようとしたけど諦めた話 in Fargate×Node.js
akihisaikeda
2
4.2k
AIキャラアプリkaiwaの低遅延音声通話基盤をどう作ったか - AWS Gravitonで支える低遅延・低コストAI Agent基盤
mogamit
0
150
Hatena Engineer Seminar #37「言語モデルの活用に関する研究」
slashnephy
0
470
Go1.27で導入されるジェネリクスメソッドでできること
mackee
0
240
ローカルLLMでどこまでコードが書けるか -縮小版 / How much code can be written on a local LLM Shortened
kishida
2
170
Semantic Version 単位で戦略を柔軟に変えて、パッケージアップデートを自動化する
daitasu
1
340
作って学ぶ、 JSX (TSX) ランタイムの基本
syumai
7
1.7k
SLOをサービス品質の共通言語にするために 取り組んできたこと
wakana0222
0
290
jQueryをバージョンアップする前に使いたいjQuery Migrate
matsuo_atsushi
0
630
SREは、MCPとSRE Agentをこう使え!
kazumax55
0
130
Featured
See All Featured
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
640
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
170
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2k
Visualization
eitanlees
152
17k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
The SEO Collaboration Effect
kristinabergwall1
1
500
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.3k
Designing Powerful Visuals for Engaging Learning
tmiket
1
440
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.5k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.1k
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