Skip to content

Navigation Menu

Sign in
Sign up

Testing

abduznik edited this page Jul 17, 2026 · 1 revision

Testing

Overview

Freegosy has 713 tests (as of v0.5.10-pre) covering unit logic, widget rendering, and integration scenarios.

Running Tests

flutter test # Full suite (~30s)
flutter test test/unit/ares_strategy_test.dart # Single file
flutter analyze # Lint check (no issues expected)

Test Structure

Directory Purpose File Count
test/unit/ Pure logic tests 42 files
test/widgets/ Widget rendering tests 6 files
test/core/ Integration-level core logic 5 files
test/health/ Smoke checks 1 file
test/ (root) Edge cases, integration, verification 4 files

Framework

  • flutter_test — core Flutter test framework
  • mockito — mock generation via @GenerateMocks annotation
  • build_runner — generates .mocks.dart files from annotations
  • http_mock_adapter — HTTP/Dio request mocking
  • fake_async — async timing control

Key Test Files

Controller Settings Regression (controller_settings_regression_test.dart — 94 tests)

  • Built-in controller mappings validation
  • POV decoding (8 cardinal + diagonal directions)
  • SDL mapping parser
  • Custom mapping persistence (round-trip, corrupt JSON, polarity-encoded keys)
  • Deadzone config (defaults, persistence, per-controller overrides)
  • PlayStation USB controller entries (PS4, PS5, PS5 Access, Sony ISE Wireless)
  • Empty-token fallback for Bluetooth noise-only controller names

Ares Strategy (ares_strategy_test.dart — 14 tests)

  • getSystemNameForSlug — correct mapping, case-insensitive, null handling
  • supportedSlugs — matches all 30 kAresSystemNames keys
  • Args regression — launch calls only pass ['--system', name], no --fullscreen/--no-file-prompt
  • Unsupported platform throws for both launch and launchWithHandle

Ares Save Strategy (ares_save_strategy_test.dart — 34 tests)

  • Extension classification per platform (confirmed/defaulted/log-only)
  • State file exclusion (.bs1-.bs9, .rtc)
  • Stem-prefix filename matching
  • restoreSave directory creation on fresh install

Save Sync Regression (save_sync_regression_test.dart — 8 tests)

  • Slot naming (always "freegosy", not timestamped)
  • Autocleanup on legacy push (true, limit 5)
  • Force push passes overwrite=true
  • Pull cooldown (second pull within 60s is skipped)
  • No pruneOldSaves in legacy push

ROM Naming (rom_naming_test.dart — 16 tests)

  • Exclamation mark sanitization
  • Bracket and whitespace handling
  • Stem-prefix matching with region/version tags

Multi-Disc Filter (multi_disc_filter_test.dart — 13 tests)

  • Filters .m3u, .cue, .ccd, .mds, .toc, .sub from launchable files

Windows Game Lookup (windows_game_lookup_test.dart — 11 tests)

  • Folder-based platforms return folder path
  • .exe detection in nested folders
  • Skips .dll/.xnb as main ROM

Windows Save Filter (windows_save_filter_test.dart — 10 tests)

  • Glob pattern matching (.ini, eeprom., saves/*)
  • Empty/whitespace patterns
  • Case-insensitive matching

Writing New Tests

For a new emulator strategy:

  1. Create test/unit/<emulator>_strategy_test.dart
  2. Test getSystemNameForSlug (if applicable)
  3. Test supportedSlugs completeness
  4. Test launch args (no invalid flags)
  5. Test unsupported platform throws

For a new bug fix:

  1. Add regression test in the relevant *_regression_test.dart file
  2. Or create test/unit/<issue>_<feature>_test.dart for issue-specific tests
  3. Lock down the exact behavior that was broken

Mock conventions:

  • Use @GenerateMocks([ServiceClass]) annotation
  • Run flutter pub run build_runner build to regenerate
  • Generated mocks go in <test_file>.mocks.dart
  • SharedPreferences mocked via SharedPreferences.setMockInitialValues({})

Clone this wiki locally

AltStyle によって変換されたページ (->オリジナル) /