Workshop Testcontainers

Schedule • Current state of testing • Testcontainers •🧪 Lab 1 •🧪 Lab 2 •🧪 Lab 3 introduction

Your test is called what?!

https://martinfowler.com/bliki/TestPyramid.html

https://martinfowler.com/bliki/TestPyramid.html

“Write tests. Not too many. Mostly integration.” https://kentcdodds.com/blog/write-tests

“You’re probably mocking too much.” https://medium.com/extreme-programming/testsdependencies-65f592a46529

Testcontainers

Testcontainers Docker

“Docker is a great abstraction”

🧪 Our Demo App • Java • Uses • Uses 17 & Spring boot a database (PostgreSQL) Keycloak for authentication • There is frontend available • Available as a Docker Image purposes for demo

🧪 Lab 1. • Goal: run the app • App consists of 4 • Database • Keycloak • Backend • User Interface manually (using Docker) parts:

🧪Lab 1.

🧪Lab 1.

🧪Lab 1.

🧪Lab 1.

🧪Lab 1.

Food :-)

🧪 Lab 2. • Goal: Test database access layer • Using JUnit test lifecycle • Using PostgreSQL Testcontainer • Using Spring Injection of properties dynamically

🧪 Lab 2.

🧪Lab Hint: 2. datasource-url wordt ook wel JDBC-url genoemd soms 😄

🧪Lab 2. • Solution • Extra nice things: - convenience annotations • Questions

🧪 Lab 3. • Goal: • With • Happy Test entire app using Testcontainers enabled authentication Duck, eh, Bug hunt!

🧪Lab 3.

Bedankt voor jullie aanwezigheid!