We are currently writing Espresso UI tests for an area of our application which requires us to clear the app data after each test
- We have tried previously using Android Orchestrator
- We have previously tried using the Android test orchestrator with the
clearPackageData=trueflag, however; this doesn’t play well with Bitrise and local test executions. For example some of us are unable to run tests locally with this flag in place, despite us invalidating the caches etc
-Our next alternative is to try and use an ADB command to clear the package data, but when we use this we are being presented with a process crashed error:
Test failed to run to completion. Reason: 'Instrumentation run failed due to 'Process crashed.''. Check device logcat for details
Test running failed: Instrumentation run failed due to 'Process crashed.'
We've tried to execute the following at the following levels:
Before the class runs Before each test After each test And we are presented with the same error each time. This is the method which we are using.
public static void clearAppData(){
try {
InstrumentationRegistry.getInstrumentation().getUiAutomation().executeShellCommand("pm clear <packageName>");
}
catch (Exception e){
e.printStackTrace();
}
}
Option: Can we do the database reset to the dB in the App itself?