3.4 KiB
3.4 KiB
Testing strategy
Framework: Swift Testing (import Testing, @Test, #expect) for all package tests. XCTest only where Swift Testing lacks support, e.g. performance measure.
Layers
| Layer | Scope | Where | Runs in make verify |
|---|---|---|---|
| Unit | Pure logic: normaliser, segmenter, router, PCM conversion, schedule ledger, cache, endpoint policy, error mapping, settings | Packages/VorleserKit/Tests/*Tests |
yes |
| Contract | Ollama client against recorded fixtures through URLProtocol stubs |
Packages/VorleserKit/Tests/VorleserOllamaTests |
yes |
| Component | SynthesisQueue + ReadingSession with FakeSynthesizer and FakeAudioPlayer (deterministic clocks) |
Packages/VorleserKit/Tests/VorleserCoreTests |
yes |
| Live integration | Real Ollama on localhost, opt-in via VORLESER_LIVE=1 |
Packages/VorleserKit/Tests/VorleserLiveTests (tagged .live) |
no; make live-test |
| Manual | Capture compatibility matrix, audio routing, UI | checklists in docs/SELECTION_CAPTURE.md and below |
no |
Rules
- Every bug fix starts with a failing test, unless it is only reproducible manually. In that case, add a manual checklist item.
- No test may depend on network, audio hardware, or Accessibility trust unless it is tagged
.liveor.manual. - Time-dependent logic (idle timeouts, the 1.5 s rule, starvation) takes an injected
Clock(any Clock<Duration>). Tests use a manual test clock. - Fakes live in the
VorleserTestSupporttarget:FakeSynthesizer(scripted chunks, latency, errors),FakeAudioPlayer,FakeCatalog,FakePasteboard,FakeAXClient. - Fixtures live inside their test target (SwiftPM resources must sit within the target):
Packages/VorleserKit/Tests/VorleserOllamaTests/Fixtures/(recorded),Packages/VorleserKit/Tests/VorleserTextTests/Fixtures/(EN article and German PDF-copy samples with hyphenation). Load them withBundle.module.
Required test cases (minimum)
Segmenter:
"z. B. die CPU"is not split after "z." ·"3.5 GHz"stays intact ·"Fig. 3 shows…"merges ·"Infra-\nstruktur"→"Infrastruktur"·"Nord-\nSüd"stays hyphenated (uppercase rule) · a 5,000-char sentence → segments ≤ 1,500 chars, no word split.
Ollama client:
- Odd-length chunk boundary preserves samples · cancellation stops the URL task · 400 unknown voice →
unknownVoicewith a parsed list · connection refused →ollamaUnreachable· request body contains only the 4 allowed keys.
Session:
- start → preparing → playing · pause during preparing remains paused when audio arrives · previousSentence at 0.8 s → previous segment, at 2.0 s → same segment · nextParagraph cancels in-flight synthesis for skipped segments · setVoice re-synthesises from the current segment · new start replaces the session and clears the cache · last segment finished → finished.
Manual release checklist
- First launch: onboarding shows correct states with Ollama stopped, model missing, AX untrusted.
- ⌥⎋ in Safari, Preview, and Word reads the selection. The source app keeps focus.
- Services menu works in TextEdit.
- Speed 0.5 / 1.0 / 2.0 sound correct (pitch preserved).
- Headphone unplug/replug during playback.
- A 10-minute read has no audible gaps (prefetch 2).
- Console.app shows no selected text in Vorleser logs.
- Quit during playback leaves no orphaned audio or network task.