Here's the breakdown:
e2e_test/ vs integration_test/ — Key Differences
1. Real Agents vs Simulated Hooks
The fundamental difference is what drives the session.
e2e_test/ launches a real AI agent (Claude Code, Gemini CLI, etc.) as a subprocess. The AgentRunner interface (agent_runner.go) actually invokes claude -p "Create a file..." and waits for it to finish. The agent creates real files, makes real API calls, and fires real hooks.
integration_test/ simulates the agent's hook lifecycle by calling the CLI hook commands directly. The HookRunner (hooks.go) manually invokes entire hooks claude-code user-prompt-submit, entire hooks claude-code stop, etc. with crafted JSON input. Transcripts are fabricated with TranscriptBuilder — no actual LLM is called.
2. Build Tags & Cost
| e2e_test/ | integration_test/ |
|---|
| Build tag | //go:build e2e | //go:build integration |
| Run command | E2E_AGENT=claude-code go test -tags=e2e | mise run test:integration |
| API calls | Yes (costs real tokens) | No |
| CI default | Excluded (opt-in) | Included in test:ci |
3. TestEnv Design
Both suites have a TestEnv but they're designed differently:
-
Integration TestEnv imports internal packages (strategy, checkpoint, paths, agent, trailers) and has rich hook simulation — SimulateUserPromptSubmit, SimulateStop, SimulatePreTask, SimulatePostTask, etc. for Claude, Gemini, and Factory Droid. It constructs fake transcripts and manually orchestrates the full session lifecycle step by step.
-
E2E TestEnv is a thinner wrapper. It has RunAgent(prompt) which delegates to the real agent binary and RunEntireEnable(strategy) which calls the actual entire enable CLI command. It doesn't import internal packages — it exercises the system purely through the CLI binary and agent subprocesses.
4. What They Test
Integration tests verify the internal machinery — hook dispatch, checkpoint creation, shadow branch management, condensation, rewind, session state transitions, etc. — with full control over inputs and deterministic behavior. They cover edge cases like mid-session commits, trailer removal, amend workflows, multi-session interleaving, and concurrent session conflicts.
E2E tests verify the end-to-end contract — "if I give Claude a prompt, does the right file get created, does the checkpoint get saved, does rewind work?" They validate that the real agent + real hooks + real CLI all wire together correctly. The test names (scenario_checkpoint_workflows_test.go, scenario_rewind_test.go, scenario_basic_workflow_test.go) reflect this scenario-level scope.
★ Insight ─────────────────────────────────────
- This is a classic test pyramid structure. Integration tests form the wide middle layer (fast, deterministic, thorough coverage of internal logic), while E2E tests form the narrow top (slow, expensive, but validate the full system wiring). The build tag separation (
integration vs e2e) lets CI run the cheap tests on every push while keeping expensive agent calls opt-in.
- The
HookRunner pattern in integration tests is a form of test double at the process boundary — rather than mocking Go interfaces, it feeds crafted JSON to the real CLI binary via stdin. This tests the actual binary's hook parsing without needing a live agent, catching serialization bugs that pure unit tests would miss.
─────────────────────────────────────────────────