Files
ClaudeDo/tests/ClaudeDo.Worker.Tests/CLAUDE.md
mika kuns d4af345ac3 test(worker): consolidate fakes into Infrastructure/, drop tag-era names
- Extract FakeClaudeProcess to Infrastructure/FakeClaudeProcess.cs (was
  defined inline in QueueServiceTests #region); all consumers updated
- Replace duplicate FakeHubContext/FakeHubClients/FakeClientProxy
  (QueueServiceTests) with existing CapturingHubContext from Infrastructure
  across all 7 affected files; Planning's file-local FakeHubContext kept
- Rename SeedListWithAgentTag → SeedListAsync (return Task<string>, drop
  unused agentTagId tuple element) and SeedListWithAgentTagAsync → SeedListAsync
- PrimeRunnerTests keeps its private nested FakeClaudeProcess: constructor
  API (delay/exitCode/lines/result params) differs from the shared one and
  replacement would require rewriting every test in that file

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-09 23:04:59 +02:00

44 lines
2.4 KiB
Markdown

# ClaudeDo.Worker.Tests
xUnit integration tests for the Worker and Data layers. One of six test projects under `tests/` (also: `ClaudeDo.Data.Tests`, `ClaudeDo.Ui.Tests`, `ClaudeDo.Localization.Tests`, `ClaudeDo.Installer.Tests`, `ClaudeDo.Releases.Tests`).
## Framework
- xUnit 2.5.3 with `xunit.runner.visualstudio`
- No mocking library — custom sealed fakes (`Infrastructure/FakeClaudeProcess`, `CapturingHubContext/CapturingHubClients/CapturingClientProxy` for SignalR; file-local fakes for scoped tests)
- Real SQLite databases per test via `DbFixture`
- Real git repos for worktree tests via `GitRepoFixture`
- coverlet for coverage collection
## Test Infrastructure
- **DbFixture** — creates unique temp SQLite DB, applies schema, cleans up DB + WAL/SHM files on dispose
- **GitRepoFixture** — creates temp git repo with initial commit, configures user/email, handles Windows read-only .git cleanup. Tests skip if git is unavailable.
## Test Areas
Tests are organized by Worker area (mirroring the source folders); 30+ test files in total. Highlights per area:
| Area | Covers |
|------|--------|
| Repositories | `ListRepositoryTests`/`TaskRepositoryTests` + config, delete-config, agent-settings, planning, orphan-guard, and roadblock variants |
| Runner | `WorktreeManagerTests`, `CommitMessageBuilderTests`, `StreamAnalyzerTests`, standalone-children routing |
| Queue / Services | `QueueServiceTests` (FIFO, override slot contention, cancellation, active tracking), `QueueServiceSlotGuardTests`, `StaleTaskRecoveryTests`, `TaskResetServiceTests`, `TaskMergeServiceTests`, `WorktreeMaintenanceServiceTests`, `AgentFileServiceTests`, `DefaultAgentSeederTests` |
| State | `TaskStateService` transition coverage |
| Planning | session manager, chain coordinator, merge orchestrator, end-to-end planning flow |
| Prime / Report / External / Lifecycle / Hub | daily prep, weekly report, external MCP tools, recovery services, hub methods |
| UiSchema / UiVm | UI-facing DTO schemas and viewmodel behavior driven from Worker fakes |
## Conventions
- Test classes implement `IDisposable` and create fixtures in constructor
- Helper factory methods for entities: `MakeTask()`, `CreateListAsync()`, `SeedListAsync()`
- Concurrency tests use `TaskCompletionSource` as gates for deterministic ordering
- Git-dependent tests are conditionally skipped via `Skip = ...` when git is not available
## Running
```bash
dotnet test tests/ClaudeDo.Worker.Tests
```