leancodepl / patrol

Flutter-first UI testing framework. Ready for action!
https://patrol.leancode.co
Apache License 2.0
891 stars 134 forks source link

App data is not cleared between test runs on iOS #1317

Open bartekpacia opened 1 year ago

bartekpacia commented 1 year ago

See also epic issue about test bundling.

When running tests on iOS, if some data is saved into, for example, NSUserDefaults during the first test, it'll be there in subsequent tests.

This behavior differs from Android. On Android, there's the great Android Test Orchestrator. It makes it easy to clear app data between test runs by setting the clearPackageData = true flag.

I searched for a solution to this problem on iOS and didn't find anything similar to Android Test Orchestrator's clearPackageData flag.

Pages I looked at:

farizkah commented 9 months ago

@bartekpacia I've tried to delete app data by following this command xcrun simctl get_app_container <device> <bundleid> data and delete the file (https://stackoverflow.com/a/56746729) and it looks like the app screen state is restored to the beginning flow (login page), as previously I have always been returned to the homepage every time I run ios test.

But the deletion I did does not restore app permission (like location and notif permission) like what android test does.

farizkah commented 9 months ago

@piotruela / @jBorkowska

mzivkovic-symphony commented 6 months ago

@bartekpacia I've tried to delete app data by following this command xcrun simctl get_app_container <device> <bundleid> data and delete the file (https://stackoverflow.com/a/56746729) and it looks like the app screen state is restored to the beginning flow (login page), as previously I have always been returned to the homepage every time I run ios test.

But the deletion I did does not restore app permission (like location and notif permission) like what android test does.

@farizkah Can you share the way how did use this command while running the tests xcrun simctl get_app_container <device> <bundleid> data ? I am looking a workaround for this bug, and it seems that i could run this command before every test so to be sure that my database file is deleted before every run. But i do not know the way to implement it in the run time, getting error ProcessException: Starting new processes is not supported on iOS when trying to run a shell command to fetch the path of the file and to delete it. Any insight would be much appreciated, since this is kinda blocking us to write the tests for iOS platform. Thank you in advance