Skip to content
Latchkey

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

Terminal
flutter --version
flutter doctor -v
flutter pub get
flutter test --coverage
flutter test --machine > test-results.json

Options

Command / flagWhat it does
flutter testRun the test suite headlessly
--coverageWrite coverage to coverage/lcov.info
--machineEmit machine-readable JSON test events
--reporter <expanded|json>Choose the test reporter
flutter doctor -vVerbose toolchain diagnostic
--android-licensesflutter 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.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →