I wrote tests in Android Studio using espresso. Now there are a number of tests that before I run I have to delete the app's cache. I tried a lot of options that I know but nothing worked out. I searched the site for the problem and tried the results but none of them worked either.
For example, there is a stage in the app that causes a change gender addressing(My app is in foreign language) and I test a number of things in this section, I log in from 3 different test users and each one has a different view that cann't change unless cache is deleted and without deleting the cache I cann't run them together but I can run each one of them separately. The app defines itself in the momnet the user logs in so to switch users I need to delete the app cache.
I attached some links here of what I tried and should have worked but didn't. They may be able to help and explain
Clear database before testcase espresso
Reset app state between InstrumentationTestCase runs
https://github.com/chiuki/espresso-samples/issues/3
https://discuss.appium.io/t/android-how-to-clear-app-data-before-test/7166/10