Problem
Current test coverage (27 tests) only covers models and validators. Missing tests for critical BLE functionality:
- BLE connection logic
- Audio packet assembly
- Codec conversion (PCM8/16, Opus)
- Platform-specific behavior
- Error recovery scenarios
Suggested Test Files
Create the following test suite:
test/services/omi/
├── omi_bluetooth_service_test.dart
├── omi_connection_test.dart
├── omi_capture_service_test.dart
├── wav_bytes_util_test.dart
└── platform_utils_test.dart
Example Tests
1. omi_bluetooth_service_test.dart
group('OmiBluetoothService', () {
test('should discover devices during scan', () async { ... });
test('should connect to device by ID', () async { ... });
test('should handle disconnection', () async { ... });
test('should auto-reconnect to paired device', () async { ... });
});
2. wav_bytes_util_test.dart
group('WavBytesUtil - Frame Assembly', () {
test('should assemble multi-packet frames correctly', () { ... });
test('should handle lost frames gracefully', () { ... });
test('should decode Opus frames to PCM', () { ... });
test('should build valid WAV header', () { ... });
});
3. omi_capture_service_test.dart
group('OmiCaptureService', () {
test('should start recording on button event', () async { ... });
test('should save recording with correct metadata', () async { ... });
test('should handle codec selection', () async { ... });
});
Mocking Strategy
Use mocktail for mocking BLE dependencies:
dev_dependencies:
mocktail: ^1.0.0
Benefits
- Catch regressions early
- Document expected behavior
- Enable confident refactoring
- Improve code quality
Priority
Medium - Important for long-term maintainability
Related
Problem
Current test coverage (27 tests) only covers models and validators. Missing tests for critical BLE functionality:
Suggested Test Files
Create the following test suite:
Example Tests
1. omi_bluetooth_service_test.dart
2. wav_bytes_util_test.dart
3. omi_capture_service_test.dart
Mocking Strategy
Use
mocktailfor mocking BLE dependencies:Benefits
Priority
Medium - Important for long-term maintainability
Related
dev-docs/suggested-testing.mdfor testing philosophy