flutter test and flutter doctor in CI
flutter test runs unit and widget tests headlessly; flutter doctor reports whether the Flutter toolchain and platform SDKs are correctly installed.
flutter doctor is the fastest way to confirm a runner is provisioned, and flutter test is the workhorse of a Flutter pipeline. Both are cheap early gates before the heavier build steps.
What it does
flutter test executes tests under test/ on the Dart VM without a device (widget tests use a headless renderer), optionally emitting coverage or machine-readable output. flutter doctor checks the Flutter install, Android/iOS toolchains, and connected devices, listing what is missing.
Common usage
flutter --version
flutter doctor -v
flutter pub get
flutter test --coverage
flutter test --machine > test-results.jsonOptions
| Command / flag | What it does |
|---|---|
| flutter test | Run the test suite headlessly |
| --coverage | Write coverage to coverage/lcov.info |
| --machine | Emit machine-readable JSON test events |
| --reporter <expanded|json> | Choose the test reporter |
| flutter doctor -v | Verbose toolchain diagnostic |
| --android-licenses | flutter doctor: accept Android SDK licenses |
In CI
Run flutter doctor -v once early so a misconfigured runner fails with a clear diagnosis. Use the subosito/flutter-action to install and cache Flutter. For Android license acceptance, flutter doctor --android-licenses mirrors sdkmanager --licenses.
Common errors in CI
"flutter: command not found" means Flutter is not on PATH; add its bin directory or use the setup action. "Android sdkmanager tool not found" or "Android licenses not accepted" from doctor is fixed by running --android-licenses. "Because ... requires SDK version ... version solving failed" is a pub constraint conflict; align the Flutter/Dart SDK version. A doctor line "cmdline-tools component is missing" means you must install cmdline-tools;latest.