既存プロジェクトのコードや設定を調べ、技術構成・設計・規約・テスト・懸念点などを7つの文書に整理します。根拠のファイルと不明点も明記し、引き継ぎに役立てます。
- 初めて触るコードの全体像を知りたいとき
- プロジェクトの引き継ぎ資料作成
- 設計資料と実装の違いを確認
Javaの結合テストで実際のデータベースなどをコンテナ起動し、接続や起動待ち、データ分離を整えます。Testcontainers 2.xへの移行にも対応します。
Write reliable integration tests in plain Java with Testcontainers 2.x: JUnit Jupiter lifecycle, singleton containers, reuse, generic containers, wait strategies, networks, init scripts, Docker Compose, CI and Docker/Podman setup. Use when adding or fixing Testcontainers tests, or migrating from 1.x. Framework-neutral.
Javaの結合テストで、データベースやメッセージ配信基盤、キャッシュをコンテナとして起動する実装を支援します。Testcontainers 2.xとJUnit Jupiterを使い、コンテナの起動・終了のタイミング、起動完了の待ち方、接続先の受け渡しを整理します。ネットワーク、初期化スクリプト、Docker Compose、CIでの実行も扱います。
本番と同じ種類・メジャーバージョンのデータベースで動作を確認したい場合に向いています。コンテナを共有しつつテストデータを分離する設計や、起動失敗の調査、1.xから2.xへの移行にも使えます。特定のアプリケーションフレームワークに依存しない内容です。
ローカルやCIにDockerなどの対応環境が必要です。Testcontainers 2.xはJUnit 4に対応していません。コンテナイメージのタグは固定し、実際の認証情報は使いません。実行間でコンテナを再利用する設定はローカル専用です。JDBCドライバーが別途必要な場合もあります。
この紹介文は、公開されている SKILL.md をもとに AI(OpenAI Codex)が作成しました。正確な仕様は下の原文を確認してください。
インストールする前に、エージェントに与えられる指示の中身を確認できます。
Run real dependencies (databases, brokers, caches) in Docker for integration tests. This skill is framework-neutral. If the project uses Spring Boot and the spring-boot-testing skill is installed, use it for @ServiceConnection, @DynamicPropertySource and test slices; for Quarkus, rely on Dev Services (Quarkus skills/docs), not hand-wired containers.
pom.xml / build.gradle) and test framework (JUnit Jupiter). Testcontainers 2.x has no JUnit 4 support.testcontainers-: org.testcontainers:testcontainers-junit-jupiter, testcontainers-postgresql, testcontainers-mysql, testcontainers-kafka, etc. (1.x: junit-jupiter, postgresql). Core stays org.testcontainers:testcontainers.org.testcontainers.postgresql.PostgreSQLContainer (1.x: org.testcontainers.containers.PostgreSQLContainer). Core classes (GenericContainer, Network, wait.strategy.*) remain under org.testcontainers.containers.PostgreSQLContainer, not PostgreSQLContainer<?>.org.testcontainers:testcontainers-bom:2.0.5 (verify the current release on Maven Central).ComposeContainer (Compose v2); DockerComposeContainer is still present in 2.0.5 (older API); prefer ComposeContainer.<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers-bom</artifactId>
<version>2.0.5</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers-junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers-postgresql</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.7.14</version>
<scope>test</scope>
</dependency>
</dependencies>
Gradle: testImplementation platform("org.testcontainers:testcontainers-bom:2.0.5"), then the same Testcontainers artifacts without versions, plus testRuntimeOnly "org.postgresql:postgresql:42.7.14". The Testcontainers module does not bundle the JDBC driver; skip the explicit driver when the project already depends on one (e.g. via Spring Boot's BOM).
import org.junit.jupiter.api.Test;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;
import org.testcontainers.postgresql.PostgreSQLContainer;
@Testcontainers
class CustomerStoreIT {
@Container
static final PostgreSQLContainer POSTGRES = new PostgreSQLContainer("postgres:17-alpine");
@Test
void connects() throws Exception {
try (var c = java.sql.DriverManager.getConnection(
POSTGRES.getJdbcUrl(), POSTGRES.getUsername(), POSTGRES.getPassword())) {
org.junit.jupiter.api.Assertions.assertTrue(c.isValid(2));
}
}
}
Always pin the image tag (never latest); match the production major version.
| Need | Pattern |
|---|---|
| One container per test class | static @Container field |
| Fresh container per test method (slow, strong isolation) | non-static @Container field |
| One container for the whole test run (fastest) | singleton holder, see references/lifecycle-and-reuse.md |
| Keep containers between local runs | withReuse(true) + opt-in property, local only |
Prefer sharing a container and isolating data (truncate/rollback, unique schema or DB per test) over restarting containers.
GenericContainer).getMappedPort/getHost.*IT and run by failsafe (Maven) or a separate Gradle test task, so unit tests stay fast.references/lifecycle-and-reuse.md: per-class/per-method, singleton pattern, reuse, parallel runs, data isolation.references/containers-and-waiting.md: modules vs GenericContainer, wait strategies, env/config, init scripts, copy files, networks, multi-container setups, Docker Compose.references/environment-ci-troubleshooting.md: Docker/Podman/Colima setup, CI, private registries, performance, common errors, 1.x to 2.x migration table.Official docs: https://java.testcontainers.org/
Upgrading to 2.x: no dedicated migration page was found on java.testcontainers.org; read the 2.0.0 release notes https://github.com/testcontainers/testcontainers-java/releases/tag/2.0.0 and all releases https://github.com/testcontainers/testcontainers-java/releases for the target version, and prefer them over this skill when they conflict.
まだレビューはありません。使ってみた感想をお寄せください。
ログインなしで書き込めます。使ってみた感想、質問、動かなかった環境などを気軽にどうぞ。
まだコメントはありません。最初のコメントを書いてみませんか。
既存プロジェクトのコードや設定を調べ、技術構成・設計・規約・テスト・懸念点などを7つの文書に整理します。根拠のファイルと不明点も明記し、引き継ぎに役立てます。
リポジトリのAI活用準備度をAgentRCで評価し、9つの観点のスコアや改善案をHTMLにまとめます。組織独自の採点方針にも対応します。
実際のコードから言語や開発ルールを読み取り、AIコーディングエージェント向けの指示ファイルを生成。プロジェクト全体や領域別にルールを整理します。
AgentRCの準備度評価を、組織やチームの基準に合わせて調整します。チェックの重みや合格率、除外項目を設定し、CIでの合否判定にも使えます。
広告の実績データから無駄な支出と成果の高い施策を見つけ、停止・増額・検証の候補を整理します。媒体をまたぐ予算配分の見直しやA/Bテストの評価にも使えます。
指定したコードファイルに、構文や設計の理由を説明する学習用コメントを追加します。読む人の知識に合わせて解説の深さや繰り返し、注釈番号の有無を調整できます。