テスト
このリポジトリでは、SwiftPM(swift test)を中心にテストレイヤーを分けます。
レイヤー定義
Section titled “レイヤー定義”1) Unit tests
Section titled “1) Unit tests”- 対象: 純粋ロジック(副作用なし、OS依存最小)
- 実装場所:
apps/macos/Tests/ThumbThingsCoreTests/ - 実行:
just test-unit
2) Integration tests
Section titled “2) Integration tests”- 対象: Keychain / URLSession / AppState など、OS依存や副作用のある境界
- 実装場所:
apps/macos/Tests/ThumbThingsIntegrationTests/ - 実行:
just test-integration - 注意: Keychainを触るテストは将来的に「抽象化 + in-memory store」で副作用を減らすのが望ましい
3) Component tests
Section titled “3) Component tests”- 対象: View(SwiftUI/AppKit)のレンダリングスモーク、軽いレイアウト検証
- 実装場所:
apps/macos/Tests/ThumbThingsComponentTests/ - 実行:
just test-component - 注意: headless環境でフレークしやすいので opt-in にしている
4) E2E tests
Section titled “4) E2E tests”- 対象: 実アプリ起動、UI自動化、権限フローを含む実機相当検証
- 実装方針: Xcode の UI Testing(XCUITest)を採用(配布用
.app/Xcode project 導入後) - 実行:
just test-e2e(現状はスキャフォールド)
コマンド一覧(推奨)
Section titled “コマンド一覧(推奨)”just test-unitjust test-integrationjust test-componentjust test-macos(= unit)
補足: opt-in の扱い
Section titled “補足: opt-in の扱い”just test-componentは内部でTHUMBTHINGS_RUN_COMPONENT_TESTS=1を付けて実行するswift test --filter '^ThumbThingsComponentTests\\.'を直接叩く場合はTHUMBTHINGS_RUN_COMPONENT_TESTS=1が必要