2

I have to test my agreement when the app is first launched: if the user do not agree, than the app must close.

Most of the test are already working but I couldn't figure out how to test if the app has closed.

Is there any way to test this behavior and "expect for close app"?

Thanks, Ian

2 Answers2

0
  1. Run the app
  2. Initialise flutter driver.
  3. Check that flutter driver is not null
  4. Close the app (the app should be closed and not backgrounded)
  5. driver.checkHealth
Artur Korobeynyk
  • 955
  • 1
  • 9
  • 24
0

When you trigger app exit you may verify if the app was exited by its exit code

expect(exitCode, 0);

I am using this approach in my tests and it works great.

usage in a sample test: https://github.com/maheshmnj/navbar_router/blob/885c68ae974250167df3c1dccee3e6474f5ddd39/test/navbar_router_test.dart#L210

Mahesh Jamdade
  • 17,235
  • 8
  • 110
  • 131