跳转至

Testing

Testing strategy and running tests.

Running Tests

# Run all unit tests
flutter test

# Run a specific test file
flutter test test/features/inference/classifier_model_test.dart

# Run with coverage
flutter test --coverage

flutter test also checks the labelled test set and its baseline; see Test Set Evaluation.

Integration Tests

Integration tests require a connected device or emulator, with the test fixtures pushed to it first:

dart tools/testset_report.dart unpack
adb shell rm -rf /data/local/tmp/test_fixtures
adb push assets/test_fixtures /data/local/tmp/test_fixtures
flutter test integration_test/model_output_test.dart -d <device_id>

unpack is only needed for testset_eval_test.dart: it unpacks the test set zip into the folder that is pushed.

Remove the old directory first; pushing onto an existing one nests the new files inside it. From Git Bash on Windows, prefix the adb commands with MSYS_NO_PATHCONV=1 so the device paths are not rewritten.

Test Purpose
model_output_test.dart Validates ONNX model output against reference detections, checks the output size against the model config, and compares batched with single-window inference
geo_soundscape_test.dart Geo-model predictions and the audio model on a soundscape, end to end
sensitivity_pipeline_test.dart The sensitivity setting and the per-label sensitivities on the real model: exact scores without pooling, and no species lost when sensitivity goes up, for every pooling mode. Needs the unpacked test set
testset_eval_test.dart Both models on the labelled test set: detection quality, score calibration, geo-model coverage, blacklist evidence, compared with a committed baseline. See Test Set Evaluation
memory_stress_test.dart Long-running session memory profiling
inference_rate_benchmark_test.dart Inference rate the device sustains
native_mp3_file_analysis_test.dart Native MP3 decoding for File Analysis
aru_deployment_test.dart ARU deployment storage

The reference detections belong to one model. After a model change, regenerate them with python dev/run_onnx_reference.py, which rewrites assets/test_fixtures/test_windows.bin and test_windows_meta.json, and push the fixtures again. model_output_test.dart fails with a clear message when the pushed fixtures were made for a different model.

The developer's phones carry real Sessions. Run these tests on an emulator, or on a phone only with a build signed like the installed app (see AGENTS.md, Device Testing).

testset_eval_test.dart has its own baseline (test/fixtures/testset_v1_baseline.json), which flutter test checks against the shipped models and tuning. After a change to a model, a default threshold, the pooling defaults, or the score blacklist, run it and record the new baseline as described in Test Set Evaluation.

Test Structure

Tests mirror the lib/ directory structure:

test/
  features/
    inference/
      classifier_model_test.dart
      geo_model_test.dart
      inference_service_test.dart
      ...
    spectrogram/
      fft_processor_test.dart
      color_maps_test.dart
      spectrogram_painter_test.dart
    live/
      live_session_test.dart
      ...
  shared/
    ...

Test Fixtures

Test data is in assets/test_fixtures/: the reference windows for model_output_test.dart, a soundscape, an MP3, and the labelled test set as birdnet_live_testset_v1.zip (Git LFS). None of it is bundled into the app.