Hacker News new | ask | show | jobs
by maxdaten 841 days ago
honest question: how are you writing integration tests? We are writing these as separate test suite often with the same test style. And in this scenario testcontainers are very valuable.
1 comments

Why not use docker compose, bring up your infra in one container, your application in a second and your tests access it the application from a third.
Testcontainers can use docker-compose: https://java.testcontainers.org/modules/docker_compose/.

Really, you use testcontainers so that you can manage everything for your test with a single build command, instead of running something extra, then running your tests, then shutting down your docker containers. Plus, with it integrated into your test suites, you can run code against your docker containers on setup/teardown, before/after container start, before/after each test, etc.

Because you don't have to muck around with docker-compose. I guess some people might find that more attractive.
You'd probably need it for the development environment anyway so you might as well reuse it
Meanwhile docker compose selling point: 'because you don't have to muck around with testcontainers; I guess some people might find that more attractive'.
Oh, absolutely! And as the other guy pointed out, docker-compose can be quite reusable when developing locally if you write it right.

But at $WORKPLACE we often use pytest-xprocess to start the required app in the same container where the tests run. It's probably the easiest way mostly because a custom wrapper does all the heavy lifting (starts the app, checks that it is running and responding to requests before the tests start, correctly terminates it when tests end).