Created
July 4, 2018 13:17
-
-
Save dominicthomas/767b1c7eb19d303f622c191bd105394e to your computer and use it in GitHub Desktop.
Script that could be used to prepare and run ui tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
EMULATOR_NAME=$1 | |
USER_NAME=$2 | |
ENVIRONMENT=$3 | |
# Start an emulator | |
${ANDROID_HOME}/tools/emulator -avd ${EMULATOR_NAME} -wipe-data & | |
EMULATOR_PID=$! | |
# Wait for Android to finish booting | |
WAIT_CMD="$ANDROID_HOME/platform-tools/adb wait-for-device shell getprop init.svc.bootanim" | |
until $WAIT_CMD | grep -m 1 stopped; do | |
echo "Waiting..." | |
sleep 1 | |
done | |
# Disable animations | |
${ANDROID_HOME}/platform-tools/adb shell settings put global window_animation_scale 0.0 | |
${ANDROID_HOME}/platform-tools/adb shell settings put global transition_animation_scale 0.0 | |
${ANDROID_HOME}/platform-tools/adb shell settings put global animator_duration_scale 0.0 | |
# Unlock the Lock Screen | |
#$ANDROID_HOME/platform-tools/adb shell input keyevent 82 | |
# Clear and capture logcat | |
${ANDROID_HOME}/platform-tools/adb logcat -c | |
${ANDROID_HOME}/platform-tools/adb logcat > build/logcat.log & | |
LOGCAT_PID=$! | |
# Run the tests and open report if there is a failure | |
if ! ./gradlew :<app-name>:connectedAndroidTest -i -Porchestrator=true ; then | |
open <app-name>/build/reports/androidTests/connected/flavors/<flavour>/index.html | |
fi | |
# Stop the background processes | |
kill ${LOGCAT_PID} | |
kill ${EMULATOR_PID} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment