一键导入
integration-test-pattern
Trigger: testing external dependencies, databases, queues, testcontainers. Prefer real dependencies over mocks for integration-level tests.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Trigger: testing external dependencies, databases, queues, testcontainers. Prefer real dependencies over mocks for integration-level tests.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | integration-test-pattern |
| description | Trigger: testing external dependencies, databases, queues, testcontainers. Prefer real dependencies over mocks for integration-level tests. |
Load this skill when a test needs to exercise a real external dependency —
a database, a queue, a cache, or another service the code under test talks
to. This includes any test tagged as an integration or acceptance scenario
in Gherkin (PRD §2, the gate_integration/gate_e2e steps of §4.5).
FreIA prioritizes integration tests with real dependencies (via
testcontainers, or the project's local docker-compose.dev services)
over mocked unit tests wherever the behavior under test crosses a real
boundary (SQL, message broker, HTTP client to a third party). Mocks hide
integration bugs; a testcontainers-backed test catches them.
testcontainers (or the local
docker-compose.dev services) — never a mock of the driver/client for
these boundaries.devenv shell
with no cloud-only infra.freia-quality-gates.sh's
gate_integration step (PRD §2.2) and run in CI; they may be skipped
selectively during a fast inner loop via the script's flag surface
(--skip-e2e, --only <gate>), but DONE always requires the full gate
run.Testing a UserRepository.Save(ctx, user) error method backed by Postgres:
testcontainers in the test's
setup (or reuse the project's docker-compose.dev postgres service),
migrated with the project's actual schema.sql.DB or in-memory fake.Save with a valid user, then read it back via a
direct query and assert the row matches.Save twice with the same unique email and assert
the real unique-constraint violation surfaces as the repository's own
domain error, not a raw driver error leaking through.This test would not catch a real unique-constraint violation if sql.DB
were mocked — the constraint lives in Postgres, not in application code.