Flutter
Published in

Flutter

Updates on Flutter Testing

Updated integration testing that supports Firebase Test Lab on mobile; stand-alone support for web and desktop, too!

Getting started with integration_test

Using the integration_test plugin requires two steps. First, add the plugin to your pubspec.yaml file as a development dependency, and use flutter pub get to pull the plugin into your project:

# pubspec.yaml

dev_dependencies:
flutter_test:
sdk: flutter
integration_test: ^1.0.0
$ flutter drive \
--driver=test_driver/integration_test.dart \
--target=test/widget_integration_test.dart
Flutter integration_test in action

Running on Firebase Test Lab

After you know that your tests work locally using either virtual or physical hardware, you can set your app loose on the plethora of devices available through Firebase Test Lab.

Firebase Test Lab console

Migrating from Flutter driver tests

For those of you with existing flutter_driver tests, moving to the new API isn’t too difficult. In addition to the appropriate initialization that was previously mentioned, you also need to move to the new WidgetTester API.

flutter_driver API (left) vs. WidgetTesting API (right)

Native UI testing

If you have an existing Android or iOS app to which you’re adding Flutter using Add-to-App, then you’re likely to have existing integration tests for those native apps that you want to leverage. In that case, add the tests for your Flutter screens to those existing tests. For Android, you can add the tests if they’re written using the Espresso framework using the espresso plugin, which provides bindings for Espresso tests of Flutter Android apps. We’ll have a similar plugin to support native iOS tests created using Earl Grey soon.

Summary

This announcement presents a new foundation for integration testing using the new integration_test plugin for Flutter. Not only is the API simpler and more consistent, tests written using integration_test can run on hundreds of different devices using the Firebase Test Lab. The Flutter team plans to build on this new foundation by updating the flutter create template to use integration_test out of the box, adding updates to the test output to support existing testing tools using the JUnit format, adding the ability to take screenshots during tests for golden testing comparisons, and more. For the full list of details about our new integration testing recommendations for your Flutter apps and plugins, see the testing docs on flutter.dev.

--

--

Flutter is Google's mobile UI framework for crafting high-quality native interfaces on iOS, Android, web, and desktop. Flutter works with existing code, is used by developers and organizations around the world, and is free and open source. Learn more at https://flutter.dev

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Chris Sells

Chris Sells is a Google Product Manager on the Flutter development experience. He enjoys long walks on the beach and various technologies.