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
Self-Contained integration tests with Docker an...
Search
Michael Vitz
September 07, 2018
Programming
250
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
100
JCON 2020: Java & Spring Boot im Container
michaelvitz
0
210
Java & Spring Boot im Container
michaelvitz
0
310
Geektastic Connect: Einführung in Web-Components
michaelvitz
0
100
JVM-Con 2019: Einführung in Web-Components
michaelvitz
0
120
JCON 2019: Einführung in Web-Components
michaelvitz
1
200
Neues von Java und dem JDK
michaelvitz
2
140
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
Lemonade + Foundry Toolkit でお手軽アプリ開発
seosoft
1
360
TSKaigi Night Talks 2026_TypeScriptでサプライチェーンの整合性を型に閉じ込める
geekplus_tech
0
400
技術的負債解消で開発者の未来を開く- AIの力でコード刷新
kmd2kmd
0
110
Performance Engineering for Everyone
elenatanasoiu
0
190
ユニットテストの先へ:テスト技法で要求・仕様を整理するJava開発実践 / Beyond_Unit_Testing_Practical_Java_Development_Techniques_for_Organizing_Requirements_and_Specifications
shimashima35
0
410
「AIで開発し、AIを届ける」をEvalでつなぐ 〜AIネイティブに始めるプロダクト開発の実践〜 / Connecting "Develop with AI, deliver AI" with Eval
rkaga
4
5.3k
スマートグラスで並列バイブコーディング
hyshu
0
230
Composerを使ったサプライチェーン攻撃の様子を眺めてみる #phpstudy
o0h
PRO
2
250
AIだと陥りがちなJakarta EE最新技術への移行時の落とし穴と解決策
tnagao7
0
110
Java × distroless で 軽量なコンテナイメージを / Java on Distroless
contour_gara
0
550
さぁV100、メモリをお食べ・・・
nilpe
0
150
ADKを使って簡単にAIエージェントを作ってみよう
k1mu21
0
270
Featured
See All Featured
Un-Boring Meetings
codingconduct
0
320
How to build a perfect <img>
jonoalderson
1
5.7k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
240
A Soul's Torment
seathinner
6
3k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
11k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
390
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.8k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
250
Evolving SEO for Evolving Search Engines
ryanjones
0
220
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
340
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
160
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