-
Notifications
You must be signed in to change notification settings - Fork 1
Running and writing tests
Dart tests are written using the flutter_test
package's API,
named with the suffix _test.dart
, and placed inside the
test/
subdirectory of the package under test.
We support several kinds of tests:
-
Unit tests, e.g. using
flutter_test
. See below. -
End-to-end tests, e.g. using
flutter_driver
)..
Flutter tests use the flutter_test
package (source, API documentation),
which provides flutter-specific extensions on top of the Dart test
package.
To automatically find all files named *_test.dart
inside a package's test/
subdirectory, and
run them inside the headless flutter shell as a test, use the flutter test
command.
Individual tests can also be run directly, e.g.: flutter test my_app_test.dart
Unit tests run with flutter test
run inside a headless flutter shell on your workstation,
you won't see any UI. You can use print
to generate console output or you can interact
with the Dart VM via the Dart Observatory at http://localhost:8181/.
To debug tests in Observatory, use the --start-paused
option to start the test in a
paused state and wait for connection from a debugger. This option lets you set breakpoints
before the test runs.
Instrumented tests run with flutter drive --target=test_driver/app.dart --driver=test_driver/*_test.dart
run on an emulator or your own device. You can run all the tests by using test_integration.sh.
To learn how to see how well tested the codebase is, see Test coverage.
Minitel Toolbox • Write Test Find Bug • Embrace the Yak Shave