android-emulator-runner
android-emulator-runner copied to clipboard
Add option to not kill emulator immediately
I'm currently debugging an issue that's happening when I run Espresso tests on an emulator in a Github workflow, and I want to be able to extract the logs from the emulator to investigate.
The problem is that as soon as the connected...Test command fails, this tool runs adb -s emulator-5554 emu kill, taking down the emulator and the logs with it. It would be great to have an option to support running commands after the script before the emulator is killed.
Alternatively, allowing multi-line scripts to continue even if an individual line fails would also work. https://github.com/ReactiveCircus/android-emulator-runner/blob/main/src/main.ts#L179 seems to prevent this.
Had the same problem when I wanted to screenshot the device after failing tests.
Have a workaround. Run the tests, take note of the status, but do not let the outside world know it yet, run your other things and only then return the original test status.
script: |
./gradlew connectedCheck || touch sorry_but_tests_are_failing
adb shell screencap /data/local/tmp/screen.png
adb pull /data/local/tmp/screen.png
test ! -f sorry_but_tests_are_failing
Full example - https://github.com/ViliusSutkus89/TestingStorageAccessFrameworkClients/blob/master/.github/workflows/build.yml
Thanks for the example, that's exactly what I needed. For testing purposes, I ended up using || true, so thanks for the way to pass on whether or not the tests actually failed!
@kschults , now your build badge might not be green anymore :laughing:
Seems like this is resolved, so I will close this out.