Say it works on my machine one more time… I dare you!

A presentation at Devoxx Poland in June 2023 in Kraków, Poland by Oleg Šelajev

Slide 1

Slide 1

Say it works on my machine one more time… I dare you! Oleg Šelajev

Slide 2

Slide 2

What actually drives productivity?

Slide 3

Slide 3

What actually drives productivity? The developer-centric approach to measuring and improving productivity. Abi Noda, DX Margaret-Anne Storey, University of Victoria Nicole Forsgren, Microsoft Research Michaela Greiler, DX / / https: queue.acm.org/detail.cfm?id=3595878

Slide 4

Slide 4

Feedback flows

Slide 5

Slide 5

Cognitive load

Slide 6

Slide 6

Flow state

Slide 7

Slide 7

Oleg Šelajev Developer relations

Slide 8

Slide 8

Slide 9

Slide 9

Tests are essential

Slide 10

Slide 10

Slide 11

Slide 11

Great tests improve Feedback loops Flow state Cognitive load

Slide 12

Slide 12

With bad tests nothing will help your developer productivity*

Slide 13

Slide 13

❌ Can’t run locally Break on changes Flaky runs Slow pipelines

Slide 14

Slide 14

✅ Novel Reproducible Significant

Slide 15

Slide 15

How to do tests?

Slide 16

Slide 16

Slide 17

Slide 17

e2e Integration tests Unit tests

Slide 18

Slide 18

Integration Testing transformation over the years Timeline Mocking Local DBs VMs (Vagrant)

Slide 19

Slide 19

Integration Testing transformation over the years Timeline Docker Docker Compose Docker API

Slide 20

Slide 20

• Container lifecycle & cleanup • Container & service configuration • Integration with frameworks or tests

Slide 21

Slide 21

• Container lifecycle & cleanup • Container & service configuration • Integration with frameworks or tests

Slide 22

Slide 22

Testcontainers-java • Created 7 years ago (Docker is 8 years old) • github.com/testcontainers/testcontainers-java • Uses docker-java API • Integrates with frameworks, like Spring, JUnit • Works with anything that runs in a Docker container

Slide 23

Slide 23

Growing ecosystem of modules

Slide 24

Slide 24

testcontainers.com/modules

Slide 25

Slide 25

testcontainers.com/modules

Slide 26

Slide 26

Why are Testcontainers - 🏆🏆🏆 ● Flexible lifecycle API: isolation vs convenience ● Capable of abstractions (modules) ● Waiting strategies ● Complex network topologies ● Automatic cleanu p ● Everything is dynamic allowing parallelisation

Slide 27

Slide 27

🏆🏆🏆 Feels like a unit, reliable like integration

Slide 28

Slide 28

Environment parity

Slide 29

Slide 29

Dev Prod

Slide 30

Slide 30

Dev CI Prod

Slide 31

Slide 31

Slide 32

Slide 32

● Using Docker-in-Docker (DinD) ● Testcontainers Cloud setup ● Parallelisation https://www.atomicjar.com/2023/01/running-testcontainers-tests-on-gitlab-ci/

Slide 33

Slide 33

Parallelization ● Surefire plugin ○ parallel=classes ○ forkCount=N ○ reuseForks=true ● Showcase ○ github.com/testcontainers/testcontainers-showcase https://maven.apache.org/surefire/maven-surefire-plugin/examples/fork-options-and-parallel-execution.html

Slide 34

Slide 34

Slide 35

Slide 35

Slide 36

Slide 36

Local development environment with SpringBoot 3.1 https://docs.spring.io/spring-boot/docs/3.1.0-SNAPSHOT/reference/htmlsingle/#features.testing.testcontainers.at-development-time

Slide 37

Slide 37

What’s next? — testcontainers.com — testcontainers.cloud — slack.testcontainers.org