Flutter Driver hangs at splash screen
Asked Answered
D

1

0

I am trying to setup Flutter Driver tests for my application and the app runs async so I found https://github.com/flutter/flutter/issues/41029 which says all you need to do is add await driver.waitUntilFirstFrameRasterized(); and it should work, while this does stop the test from failing it nos simply does not run.

The app just hangs at the splash screen never even getting into the application itself.

As far as I am understanding, this is all I would need to have setup in order for the test to run

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

    // await Directory('screenshots').create();
  });

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

However, all I am getting in my terminal is the following output:

VMServiceFlutterDriver: Connecting to Flutter application at http://127.0.0.1:54264/tt9kN4jBSrc=/
VMServiceFlutterDriver: Isolate found with number: 2942164624858163
VMServiceFlutterDriver: Isolate is paused at start.
VMServiceFlutterDriver: Attempting to resume isolate
VMServiceFlutterDriver: Connected to Flutter application.
VMServiceFlutterDriver: waitForCondition message is taking a long time to complete...

I have left it for minutes and nothing happens, I have disabled the firebase initialization in case somehow that is blocking it as I would need to accept the alert dialogue, not that I am even getting that far as I can see.

Duress answered 12/11, 2020 at 4:18 Comment(0)
D
0

Turns out I needed to use an IsolatesWorkaround as well

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

    if (!await Directory('screenshots').exists()) {
      await Directory('screenshots').create();
    }
  });

  // Close the connection to the driver after the tests have completed.
  tearDownAll(() async {
    await driver?.close();
    await workaround.tearDown();
  });

See: https://gist.github.com/vishna/03c5d5e8eb14c5e567256782cddce8b4

Duress answered 12/11, 2020 at 9:29 Comment(3)
Any solution for flutter 2?Kirkham
@Kirkham this is all old now, there is a new integration testing framework that came out last December I think it was which mimics flutter_test, "integration_test_driver", super simple and i think like 10X faster tooDuress
I got to that conclusion as well after more research. For any lost soul ending up here due to reading old documentation, as of now, packages that help me driving the app and executing tests are: flutter_test, integration_test, and flutter_driver. Specifically driver: integration_test/integration_test_driver.dart.Kirkham

© 2022 - 2024 — McMap. All rights reserved.