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
Self-Contained integration tests with Docker an...
Search
Michael Vitz
September 07, 2018
Programming
260
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Self-Contained integration tests with Docker and Testcontainers
Michael Vitz
September 07, 2018
More Decks by Michael Vitz
See All by Michael Vitz
Spring Boot entzaubert
michaelvitz
0
110
JCON 2020: Java & Spring Boot im Container
michaelvitz
0
210
Java & Spring Boot im Container
michaelvitz
0
330
Geektastic Connect: Einführung in Web-Components
michaelvitz
0
110
JVM-Con 2019: Einführung in Web-Components
michaelvitz
0
130
JCON 2019: Einführung in Web-Components
michaelvitz
1
200
Neues von Java und dem JDK
michaelvitz
2
150
Spring Boot entzaubert
michaelvitz
0
330
Geektastic Connect: Neues von Java und dem JDK
michaelvitz
0
180
Other Decks in Programming
See All in Programming
[GoCon2026] When Goroutines Are Not Enough: Runtime Locality in High-Throughput Go
takehaya
6
2.2k
AWS DevOps Agentで インシデント対応をAIに任せたい
honmarkhunt
7
2.9k
【DroidKaigi 2026】「アクセシビリティを利用するとき、 アクセシビリティもまたこちらを利用している」 〜マルウェアによる攻撃と防衛について〜
halunoyo
0
460
モジュールの視点からSwiftを読み解く #iosdc
s_shimotori
0
170
『寄り添うラジオ』をAIで作る 体験価値から逆算した、会話しないUXと品質設計
theoriatec2024
3
180
手動確認はもう限界 〜XCUITestでCustom URL Schemeの遷移を起動種別ごとに自動テストする〜 / Testing Custom URL Schemes with XCUITest
otouto
0
260
速く作れる。その次は、速く確かめられる開発へ 〜AIネイティブ開発を支える、Shift Down〜 / Can build fast. Next, moving to development where we can verify fast.
rkaga
2
740
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
350
AHC070解法紹介
eijirou
0
110
WebRTC映像をAirPlayに対応させる挑戦.pdf
monolithic_adam
0
150
テストを司るデーモンに会いに行く 〜隔離した仮想マシンでテストを通すまで〜
h1d3mun3
1
340
Building an Out-of-Order CPU
latte72
1
770
Featured
See All Featured
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
230
The SEO Collaboration Effect
kristinabergwall1
1
560
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.9k
Building the Perfect Custom Keyboard
takai
2
870
Design in an AI World
tapps
1
320
Thoughts on Productivity
jonyablonski
76
5.4k
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
540
Claude Code のすすめ
schroneko
67
230k
How to Think Like a Performance Engineer
csswizardry
28
2.8k
Crafting Experiences
bethany
1
330
Transcript
2018-09-07 Berlin / BED-Con Self-Contained integration tests with Docker and
Testcontainers Michael Vitz https://pixabay.com/en/construction-site-crane-pier-1156575 @michaelvitz #bedcon
Michael Vitz Senior Consultant at INNOQ • Build, run, and
maintain JVM applications • JavaSPEKTRUM column owner • ❤ Clojure
www.innoq.com OFFICES Monheim Berlin Offenbach Munich Zurich FACTS ~125 employees
Privately owned Vendor-independent SERVICES Strategy & technology consulting Digital business models Software architecture & development Digital platforms & infrastructures Knowledge transfer, coaching & trainings CLIENTS Finance Telecommunications Logistics E-commerce Fortune 500 SMBs Startups
None
None
UI Integrated UI Service Service Integration Unit Implementation Unit
UI Integrated UI Service Service Integration Unit Implementation Unit https://martinfowler.com/bliki/TestPyramid.html
https://www.thoughtworks.com/de/insights/blog/introducing-software-testing-cupcake-anti-pattern https://labs.spotify.com/2018/01/11/testing-of-microservices Testing Pyramid Honeycomb Ice Cream Cone
None
https://8thlight.com/blog/uncle-bob/2012/08/13/the-clean-architecture.html
http://www.dossier-andreas.net/software_architecture/ports_and_adapters.html Ports-And-Adapters
None
Testcontainers • Launch Docker containers from Java • Test data
access layer • UI browser tests • Requires Docker • Requires Java 8 https://www.testcontainers.org
@ClassRule public static GenericContainer postgres = new GenericContainer("postgres:latest") .withEnv("POSTGRES_PASSWORD", "mysecretpassword");
private Connection create() throws Exception { String host = postgres.getContainerIpAddress(); int port = postgres.getMappedPort(5432); String url = "jdbc:postgresql://"+host+":"+port+"/postgres"; String user = "postgres"; String password = "mysecretpassword"; return DriverManager.getConnection(url, user, password); } Generic Containers
static String WAIT_PATTERN = ".*database system is ready to accept
connections.*\\s"; @ClassRule public static GenericContainer postgres = new GenericContainer("postgres:latest") .withEnv("POSTGRES_PASSWORD", "mysecretpassword") .waitingFor(forLogMessage(WAIT_PATTERN, 2)); Container != Application
@ClassRule public static PostgreSQLContainer postgres = new PostgreSQLContainer() .withPassword("mysecretpassword"); private
Connection create() throws Exception { String url = postgres.getJdbcUrl(); String user = postgres.getUsername(); String password = postgres.getPassword(); return DriverManager.getConnection(url, user, password); } Database Container
@Rule public BrowserWebDriverContainer chrome = new BrowserWebDriverContainer() .withDesiredCapabilities(DesiredCapabilities.chrome()) .withRecordingMode(RECORD_ALL, new
File("build")); @Test public void test() { WebDriver driver = chrome.getWebDriver(); } Selenium Container
Testcontainers 2.0 • Cleanup API • Entangle from JUnit 4
rules https://github.com/rnorth/containercore/pull/1
www.innoq.com innoQ Deutschland GmbH Krischerstr. 100 40789 Monheim am Rhein
Germany +49 2173 3366-0 Ohlauer Str. 43 10999 Berlin Germany +49 2173 3366-0 Ludwigstr. 180E 63067 Offenbach Germany +49 2173 3366-0 Kreuzstr. 16 80331 München Germany +49 2173 3366-0 innoQ Schweiz GmbH Gewerbestr. 11 CH-6330 Cham Switzerland +41 41 743 0116 Thanks! Questions? Michael Vitz
[email protected]
michaelvitz +49 151 19116015 https://speakerdeck.com/michaelvitz/testcontainers https://github.com/mvitz/javaspektrum-testcontainers