使用Flutter驱动程序运行测试时未加载资产

时间:2019-05-22 02:17:30

标签: flutter flutter-test

当我使用Flutter驱动程序运行集成测试时,我发现我的应用程序中的图像根本没有加载。尽管如果我从运行状态运行应用程序,一切都会正常运行。

这是我的测试代码:

// Imports the Flutter Driver API
import 'package:flutter_driver/flutter_driver.dart';
import 'package:test/test.dart';

void main() {
  group('login page ignore', () {
    // First, define the Finders. We can use these to locate Widgets from the
    // test suite. Note: the Strings provided to the `byValueKey` method must
    // be the same as the Strings we used for the Keys in step 1.
    final ignoreFinder = find.byValueKey('ignore');
    final screenFinder = find.byValueKey('child_screen');

    FlutterDriver driver;

    // Connect to the Flutter driver before running any tests
    setUpAll(() async {
      driver = await FlutterDriver.connect();
    });

    // Close the connection to the driver after the tests have completed
    tearDownAll(() async {
      if (driver != null) {
        driver.close();
      }
    });


    test('test',() async {
      await driver.waitUntilNoTransientCallbacks();
      await driver.waitFor(ignoreFinder);
      await driver.tap(ignoreFinder);
      print('button clicked');
    });
  });
}

预期:When Run using Flutter run

实际When run test using Flutter driver

0 个答案:

没有答案