patrol icon indicating copy to clipboard operation
patrol copied to clipboard

App data is not cleared between test runs on iOS

Open bartekpacia opened this issue 2 years ago • 4 comments

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:

bartekpacia avatar May 25 '23 12:05 bartekpacia

@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 avatar Feb 01 '24 11:02 farizkah

@piotruela / @jBorkowska

farizkah avatar Feb 02 '24 16:02 farizkah

@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

mzivkovic-symphony avatar Apr 14 '24 17:04 mzivkovic-symphony