We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
🚀 Integration Testing with Docker and Testcontainers (Sergei Egorov)
Learn how to simplify integration testing with Docker and Testcontainers, a powerful combination that allows you to define and start containers, automate database setup and tearing down, and more.
- Avoid running tests on external services directly, instead, use a mocking library to isolate tests.
- Docker provides a cross-platform, unified testing environment, but static ports can cause issues.
- Use Testcontainers to simplify integration testing and avoid complex setup.
- Testcontainers provides a simple API to define containers, supports different drivers, and can register custom drivers.
-
Use the
getBootstrapServers
method in Kafka to get the bootstrap servers. - When running tests, consider using a testing framework that provides initialization and testing utilities.
-
Use
Testcontainers
to define and start containers, and to automate database setup and tearing down. -
Containerize services, and then use
Testcontainers
to start containers and run tests. -
Use
Testcontainers
to simplify testing and integrate with other testing frameworks. - Test containers works better for developers who use different operation systems.
-
Testcontainers
can be used with any framework, including Spring Boot, to simplify testing. - Docker provides a simple way to run and test services in isolation.
-
Testcontainers
provides a simple way to define and start containers for testing. -
Docker can be used to test services in isolation, but it’s more complex than
Testcontainers
. - Test containers can be used with embedded databases, but can also be used with real databases.
-
The problem with
docker-compose
is that it uses thedocker
command to run services, anddocker
command can take a long time to start services. -
Using
docker-compose
to start services can take a long time, especially with real-time databases. -
Avoid using
docker
command to run services, instead, useTestcontainers
to define and start services. -
Use
Testcontainers
to define and start containers, and to automate testing and cleanup.