Testing
Test structure
Test harness (test/support/pump_app.dart)
Key utilities
Pattern for widget tests
Pattern for handler/network tests
Mock Dio
The Dio adapter (dio_test_adapter / DioAdapter) is the primary test seam for all network-dependent code. Since every client Repository takes a Dio instance, tests can:
- Use a real
Diowith a mock adapter to test repository logic against expected HTTP calls - Use fake repository implementations to test screens without any network dependency
Repository pattern for testability
All feature repositories follow this pattern:
This makes repositories trivially testable — pass a real Dio with mock adapter, or pass a fake Dio, or override the Riverpod provider entirely.
Handler testing
Shelf handlers are testable by mounting them on a test HTTP server. Each handler (TicketHandler, CustomerHandler, etc.) receives a Shelf.Request and returns a Shelf.Response — no database dependency at the handler level (the handler delegates to a repository/service that is injected).
Anti-drift tests
The sync table registry (lib/core/sync/sync_table_registry.dart) has an anti-drift test that ensures every AppDatabase table is either:
- Registered in
kSyncTableRegistry(syncable), or - In the exclusion set (non-syncable)
This prevents silent omissions when new tables are added.