fernandoteixxeira/stark-bank-challenge/testcontainers
Claude Code and agent skill by fernandoteixxeira/stark-bank-challenge
- community
Checking that the SKILL.md file is still in the repository.
Use when running real dependencies as Docker containers from a JVM test — @Testcontainers, GenericContainer, fixed and random ports, wait strategies, container reuse, network aliases, and the Docker API version handshake.
Install
npx vskill@latest install fernandoteixxeira/stark-bank-challenge/testcontainersSKILL.md
The same SKILL.md was published earlier as fernandoteixxeira/stark-bank-challenge/testcontainers.
Testcontainers
Runs a real dependency in a container for the length of a test. Use it when a double would have to lie about the dependency's behaviour; see tdd for when a stub is the better answer.
Basics
static starts the container once per class; an instance field starts it per test method. Prefer static: container startup dwarfs the test.
Pin the tag. latest makes the suite depend on when it ran.
Ports
By default Testcontainers maps the exposed port to a random free host port — that is what lets suites run in parallel and on shared CI. Read it back:
Never hardcode the container-side port on the host side. getMappedPort is not a formality.
When a fixed port is unavoidable — a client that will not accept a port, because its URL is compiled in — bind it explicitly:
This costs what random ports buy: two such tests cannot run at once, and the port must be free on the machine. Take it only when the client leaves no choice.
A privileged port (below 1024) needs no privileges for the test process: the Docker daemon does the binding, and it is root.
Wait Strategies
The container being started is not the dependency being ready. Without a wait strategy, the test races the process inside.
| Strategy | For | |
|---|---|---|
Wait.forLogMessage(regex, times) | the process announces itself in the log | |
Wait.forHttp(path).forStatusCode(n) | it serves HTTP | |
Wait.forListeningPort() | the default; only proves something bound the port | |
Wait.forHealthcheck() | the image defines a HEALTHCHECK |
forListeningPort is the weakest and the default. If a test is flaky at startup, that is the first thing to look at.
Files
Prefer copying: bind mounts inherit host ownership, and a mode-600 file owned by the host user is unreadable to a container running as its own non-root user. That failure surfaces as whatever the process does when it cannot read a file, which is rarely "permission denied".
Networks and Aliases
An alias makes the container answer to that name for other containers on the same network. That is how a client with a hardcoded host gets redirected without touching its configuration — the same trick a Compose aliases: entry does.
It only works container to container. A test running in the JVM resolves through the host, not Docker's DNS. To redirect a hostname for the test process itself, use the JDK's own resolver:
That property makes the JDK resolve from that file and nowhere else: every name absent from it becomes UnknownHostException. Read that as a feature — a test that cannot resolve the internet cannot accidentally call it — but know that it is why an unrelated lookup suddenly fails.
The Docker API Handshake
Could not find a valid Docker environment usually does not mean Docker is missing. Read the attempted strategies underneath it:
That is a version negotiation, not an absent daemon. docker-java defaults to API 1.32, and daemons on Docker 25+ refuse anything below 1.40. Fix it with the docker-java system property:
DOCKER_API_VERSION in the environment does not reach it. Upgrading Testcontainers alone may not either, since the default lives in docker-java.
Also check the daemon's own numbers before guessing:
Version Pinning Through BOMs
If the project imports spring-boot-dependencies, it manages the Testcontainers version. Between imported BOMs the first declaration wins, so a testcontainers-bom placed after Boot's is silently ignored. Declare it first.
Reuse and Cleanup
Ryuk, a sidecar container, removes what the test created — including after a JVM crash. Do not disable it in CI.
withReuse(true) keeps a container alive between runs. It needs opt-in via testcontainers.reuse.enable in ~/.testcontainers.properties, and it leaks state between runs by design: a test that only passes on a reused container is a test that depends on the last run.
Review Checklist
- Image tags are pinned.
- Containers are
staticunless per-test isolation is genuinely needed. - Host ports come from
getMappedPort, unless a client forbids it and the reason is written down. - The wait strategy proves readiness, not just a bound port.
- No
Could not find a valid Docker environmentdiagnosed as "Docker is broken" before reading the strategy list.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryChecking.skills/testcontainers/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/fernandoteixxeira/stark-bank-challenge/testcontainers)