Issue
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=true
flag, 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?
Solution
It will likely be easiest to have the development team enable a DB reset function inside the app when running in a debug version. Ideally it’d be a button on the initial screen so you don’t have to do much work to get to it, unless your app returns to the previous state between tests (I don’t have a functioning environment in front of me to check) in which case that code is going to get messy.
You’re correct that the methods you’ve mentioned in your question will not work; abandon them.
Answered By - Mike Collins
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.