chiuki / espresso-samples

A collection of samples demonstrating different Espresso techniques.
Apache License 2.0
635 stars 156 forks source link

Need a helper method to clear app data and then continue running test cases #3

Closed shashikumarraja closed 7 years ago

shashikumarraja commented 7 years ago

Just like the rotate-screen method you have created can you help me in creating a method to clear user data(Which should work same as going to app info>>storage>>clear data) I am trying to automate the Onboarding process and need to clear app data before each test run. So far I have found ways to run adb commands to clear data but using that closes the app thus failing the tests. I need to use the method in @Before of the test suite so that before each test execution the data is cleared.

chiuki commented 7 years ago

Rather than clearing user data during test, I recommend setting up dependency injection so you are modifying an in-memory SharedPreferences instead, so it always starts off with nothing. See https://github.com/chiuki/friendspell for an example.