Testing
One command
./tool/test_all.sh
# → dart format --set-exit-if-changed .
# → flutter analyze
# → flutter test
# → golden diff (with CI image regeneration guidance)
Separate headful:
flutter test test/design_system --reporter expanded
flutter test integration_test/app_test.dart -d chrome
Pyramidal breakdown
| Layer | Where | What |
|---|---|---|
| Unit (exhaustive) | test/unit/**, test/core/**, test/design_system/*_test.dart | lifecycle vectors, deadline boundary, contest graphemes 10/2000, namespace mapping, token scales, contrast |
| Widget | test/widget/**, test/features/*/presentation/*, test/foundation/**, test/router/** | hub selector/tab/banner, charge detail field visibility, contest disabled/enabled, keyboard (Enter/Space), focus ring, semantics heading/button/liveRegion, 360–1440 no overflow, RTL, light/dark |
| Golden | test/golden/** (10 design baselines + hub/charge variants) | pixel proof of KxBanner, KxCard, KxPhotoStrip, etc. Harness pins DPR 1.0, surface, NoSplash. Linux CI must regenerate once (wave 2 vs Linux rasterization delta) |
| Architecture | test/architecture/** | dependency cycle forbids: design_system no feature import, features no ad-hoc Navigator |
| Contract | test/helpers + test/router/…_test.dart | fixture manifest hash check, router table vs KxRoutes, l10n parity |
| Integration | integration_test/app_test.dart | fixture boot → hub → inspection → charge → contest → history → statement → pay → reload persistence; uses integration_test + WebDriver |
Determinism tactics
AppConfig.fixtureDefaults()avoids env;ManualClock-equivalent supplied viaAnchoredDemoClockat fixed instant for deadline widget tests.GetItreset persetUp/tearDownto isolate DI.- No
print— logs go viamaybeLog*and are asserted viatestprintsmatcher only where explicitly expected.
Goldens
Deterministic harness in test/golden/support/golden_harness.dart wraps each component with MediaQueryData(size, textScaler, brightness, disableAnimations) + Directionality. Failure message points at flutter test --update金? Use flutter test --update-goldens on pinned image (netlify.toml toolchain) and visually inspect before commit.
Evidence
tool/aggregate_evidence.dart and tool/check_evidence.dart validate docs/evidence/manifest.yaml SHA hashes; tool/android_runtime_proof.sh captures adb logcat + instrumentation for device proof. Part 8B must collect final evidence post-Part 7 merges (ADRs in docs/adr/).
What is not tested headlessly
Browser zoom, TalkBack/native screen reader announcement order, hosted SPA fallback — manual runtime per parts_plan.md §12 evidence ledger.
Coverage aspiration
Frontend has no hard coverage floor (unlike backend 85% branch) but every P0/P1 ID must map to at least one automated or manual evidence row before delivery — see ledger in plan.md §3.