Android Instrumentation Test clearPackageData: 'true' does now write result to file

627 views Asked by At

I have Instrumentation Test with Espresso. I have a test watcher that write a result to a file in device sdcard, then I will pull the file using adb command.

However when I use orchestrator and enable this config:

testInstrumentationRunnerArguments clearPackageData: 'true'

Then, it does not write the result to the file in sdcard.

Does anyone know why it happened? and any solution for it to keep writing on the file in sdcard?

Thank you.

1

There are 1 answers

0
hallz12 On

It is because the permission was revoke for each test. So, I have to add:

InstrumentationRegistry.getInstrumentation().uiAutomation.executeShellCommand("pm grant com.traveloka.android.staging android.permission.WRITE_EXTERNAL_STORAGE")

in my test watcher.