Skip to content

Testing on container

Thang Chung edited this page May 14, 2021 · 1 revision
  1. Orchestration — how do you know when Redis will be ready to receive traffic after you start it? You’d need some kind of health check and waiting strategy.
  2. Parallelism — Since port 6379 will be allocated, you cannot run multiple tests in parallel. You could choose not to expose that specific port and the - Docker daemon would automatically bind it to a random free port on your machine, but then you wouldn’t know what port to connect to from your tests to interact with Redis.
  3. Test lifecycle — normally you would want to recreate the container in between tests to have an isolated and clean environment for each test scenario.
  4. Cleanup — You need to stop and remove the container after your tests run.

Ref at https://medium.com/@jdelucaa/integration-testing-with-docker-and-testcontainers-3e53e6f44a1b

Some approaches

Clone this wiki locally