0

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
shawnblais
  • 1,038
  • 11
  • 23

2 Answers2

0

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!

shawnblais
  • 1,038
  • 11
  • 23
0
test('Check flutter driver health', () async {
      Health health = await driver.checkHealth();
      print(health.status);
    });
  • 1
    Please don't post only code as answer, but also provide an explanation what your code does and how it solves the problem of the question. Answers with an explanation are usually more helpful and of better quality, and are more likely to attract upvotes. – Mark Rotteveel Jun 27 '21 at 10:13
  • This returns on Bad, or Good as state. We're trying to check specific values, like `appModel.currentUser` and make sure they have been set correctly. – shawnblais Jun 27 '21 at 17:35