main_test.dart.tmpl 1.17 KB
Newer Older
1 2 3 4 5
// This is a basic Flutter Driver test for the application. A Flutter Driver
// 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.
6

7 8 9
import 'package:flutter_driver/flutter_driver.dart';
import 'package:test/test.dart';

10
void main() {
11 12 13 14 15 16 17 18 19
  group('end-to-end test', () {
    FlutterDriver driver;

    setUpAll(() async {
      // Connect to a running Flutter application instance.
      driver = await FlutterDriver.connect();
    });

    tearDownAll(() async {
20 21
      if (driver != null)
        driver.close();
22 23 24
    });

    test('tap on the floating action button; verify counter', () async {
25
      // Finds the floating action button (fab) to tap on
26
      SerializableFinder fab = find.byTooltip('Increment');
27 28 29

      // Wait for the floating action button to appear
      await driver.waitFor(fab);
30 31

      // Tap on the fab
32
      await driver.tap(fab);
33 34

      // Wait for text to change to the desired value
35
      await driver.waitFor(find.text('Button tapped 1 time.'));
36 37 38
    });
  });
}