How to check application state with FlutterDriver?

77 Views Asked by At

We're building some integration tests with FlutterDriver, and would like to verify the state of the application.

It seems flutter drive runs in a totally different instance than the app, so they can not communicate indirectly by stashing data in some shared static class.

Are there any common strategies to passing data to the test layer, from the app?

Some ideas I thought of:

  • We could write json values to disk, but can the test side actually read it?
  • Have a hidden text widget, that shows a special ui view that renders state so we can then read it from the test layer
2

There are 2 best solutions below

0
On

fwiw, we have solved this currently by json-encoding some of our app state into an invisible Text widget that we place on screen.

The test can then lookup that text, decode the json, and read the current app state.

Pretty hacky but it works!

2
On
test('Check flutter driver health', () async {
      Health health = await driver.checkHealth();
      print(health.status);
    });