testing / ci workflow for flutter apps
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.idea
android
ios init Dec 16, 2018
lib integration test config :: travis ci config Jan 17, 2019
scripts integration test config :: travis ci config Jan 17, 2019
test integration test config :: travis ci config Jan 17, 2019
test_driver updates readme :: adds build status badge Jan 17, 2019
.gitignore init Dec 16, 2018
.metadata init Dec 16, 2018
.travis.yml removes verbose Jan 17, 2019
LICENSE Initial commit Dec 16, 2018
README.md
pubspec.yaml integration test config :: travis ci config Jan 17, 2019

README.md

Build Status codecov

flutter testing workflow

  • unit tests
  • widget tests
  • integration tests
  • travis config
  • codecov config

shout out to the mmcc007/flutter_app for the excellent travis config example

unit / widget tests

flutter tests --coverage

integration tests

Flutter Integration Testing Docs

create a directory called test_driver in app root

test_driver/main.dart - enable extension and drive app

   import 'package:flutter_driver/driver_extension.dart';
   import 'package:flutter_flow/main.dart' as app;
   
   void main() {
     // Enable integration testing with the Flutter Driver extension.
     // See https://flutter.io/testing/ for more info.
     // This line enables the extension
     enableFlutterDriverExtension();
     // Call the `main()` of your app or call `runApp` with whatever widget
     // you are interested in testing.
     app.main();
   }

test_driver/main_test.dart - integration tests

   // test is an end-to-end test that "drives" your application from another
   // process or even from another computer. If you are familiar with
   // Selenium/WebDriver for web, Espresso for Android or UI Automation for iOS,
   // this is simply Flutter's version of that.
   
   import 'package:flutter_driver/flutter_driver.dart';
   import 'package:test/test.dart';
   
   void main() {
     group('end-to-end test', () {
       FlutterDriver driver;
   
       setUpAll(() async {
         // Connect to a running Flutter application instance.
         driver = await FlutterDriver.connect(
           timeoutMultiplier: 4,
           printCommunication: true,
         );
       });
   
       tearDownAll(() async {
         if (driver != null) driver.close();
       });
   
       test('tap on the floating action button; verify counter', () async {
         // Finds the floating action button (fab) to tap on
         SerializableFinder fab = find.byTooltip('Increment');
   
         // Wait for the floating action button to appear
         await driver.waitFor(fab);
   
         // Tap on the fab
         await driver.tap(fab);
   
         // Wait for text to change to the desired value
         await driver.waitFor(find.text('1'));
       });
     });
   }

running integration tests

flutter drive --target=test_driver/main.dart