Description
A very common use case for the android-emulator-runner is to run Android tests using Espresso. Per default, Espresso creates a dump of the view hierarchy and a screenshot when a test fails. These files are very helpful when debugging failed tests.
However, getting them from the emulator was somewhat tricky: Since the script execution of a script is stopped on an error (and a failed test is an error), the files cannot be pulled easily. If the failed test error is suppressed, the action will run as passed and not show the failed test immediately. It would be possible to save the snapshot of the AVD and start it again in a second step, but this does not seem to be very efficient.
I came up with this solution, but I do not like it a lot:
EXIT_CODE=0 && ./gradlew connectedCheck || EXIT_CODE=$? && (adb pull /sdcard/googletest/test_outputfiles app/build/outputs/androidTest-results/ || true) && exit $EXIT_CODE
Is there an easier way to do it? If not, I would like to have either the possibility to use a tear-down script that can be run before the emulator is shut down or be able to indicate a list of folders/files to be pulled from the AVD after executing the script.