This guide defines how idx0 tests are organized, how to add new tests, and which gates to run before merging.
- Protect behavior at service/domain boundaries first.
- Keep tests deterministic and filesystem-isolated.
- Prefer focused unit tests with lightweight stubs over broad end-to-end suites.
- Use integration tests selectively for IPC, git worktree lifecycle, and persistence reload behavior.
Main test target: idx0Tests
Key suites:
- Session domain:
SessionServiceTests.swiftSessionServiceTests+Launch.swiftSessionServiceTests+Niri.swiftSessionServiceIntegrationTests.swift
- Workflow domain:
WorkflowServiceTests.swiftWorkflowModelsTests.swiftSupervisionQueueServiceTests.swift
- Git/worktree/runtime utilities:
GitServiceParsingTests.swiftWorktreePathGenerationTests.swiftAutoCheckpointServiceTests.swiftAgentOutputScannerTests.swift
- Command/keyboard/settings:
AppCommandRegistryTests.swiftKeyboard/ShortcutRegistryTests.swiftAppSettingsKeyboardTests.swift
- Runtime integration packages:
Apps/VSCode/VSCodeRuntimeTests.swiftApps/T3Code/T3CodeRuntimeTests.swiftApps/Excalidraw/ExcalidrawRuntimeTests.swift
- Test name format:
test<BehaviorUnderCondition>() - Arrange/act/assert should be readable without helper indirection unless repeated heavily.
- Prefer one behavior assertion focus per test.
- Use extensions (as done for
SessionServiceTests) to keep large domains grouped by concern.
Patterns already used in repo:
- Temporary root directories per test to isolate persistence.
- Local fixture builders (
Fixture,makeService) for domain wiring. - Protocol-backed stubs for external effects (
ProcessRunnerProtocol,GitServiceProtocol). - Minimal test doubles for runtime tile controllers (see Niri app tracker stubs).
Recommended approach:
- Define protocol seam in production code if none exists.
- Build tiny in-test stub with explicit expectations.
- Assert both outputs and important side effects.
- State mutation in service collections.
- Callback behavior.
- Persistence side effects when relevant.
- Attention/queue/session focus invariants.
- Router request validation.
- Success and error response shape.
- CLI mapping where applicable.
- Decode default behavior for missing field.
- Round-trip encode/decode.
- Behavioral effect in service/UI entry points.
- Manifest generation.
- Wrapper fallback behavior.
- Launch status reporting.
- Restrictions/degraded path behavior.
- Workspace invariants.
- Focus/camera updates.
- Tile controller lifecycle and cleanup.
Run full test suite:
xcodebuild -project idx0.xcodeproj -scheme idx0 -destination 'platform=macOS' testMaintainability gate:
./scripts/maintainability-gate.shCore coverage gate:
./scripts/coverage-core.shCoverage scope is limited to:
idx0/Services/**idx0/Models/**idx0/Persistence/**idx0/Utilities/**
- Targeted tests for touched areas.
./scripts/maintainability-gate.sh- Full
xcodebuild ... test ./scripts/coverage-core.sh(when environment supports full code-sign/test run)
Observed during docs audit:
./scripts/coverage-core.shcan fail on some machines during framework code-sign with:errSecInternalComponentCommand CodeSign failed with a nonzero exit code
When this occurs:
- Record the failure in PR validation notes.
- Still run targeted/full tests when possible.
- Re-run in a machine/profile with valid local signing context.
- Tests added/updated for new behavior.
- No obvious regression gaps in changed domain.
- Maintainability gate run and reviewed.
- Full test run attempted; failures triaged and explained.
- Coverage gate attempted for non-trivial core logic changes.