How to start the Android Emulator from the terminal command line. It‘s helpful if you want to automate Android testing on an emulator locally on your Mac machine. Add below commands to a shell script and then just run your Android Espresso tests.
Script starts emulator, runs gradle command $gradle cAT, then shuts down emulator.
Start Android emulator:
- Go to your Android sdk directory (ex: open terminal and $cd Users/engineering/Library/Android/sdk/tools/emulator) and enter below command:
/Users/engineering/Library/Android/sdk/tools/emulator -avd Nexus-6-API-28 -wipe-data -no-boot-anim -screen no-touch & EMULATOR_PID=$!
The Android Emulator starts running on your computer. Add below command; waits for Android emulator to finish booting:
WAIT_CMD=”/Users/engineering/Library/Android/sdk/platform-tools/adb wait-for-device shell getprop init.svc.bootanim”until $WAIT_CMD | grep -m 1 stopped; doecho “Waiting…”sleep 1done
Run Espresso test suite on a connected Android emulator:
# Run Acceptance Test Suite
./gradlew :tunein:connectedGoogleFlavorFreeX86DebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=myApp.suite.AcceptanceTestSuite
Kill Android emulator:
cd /Users/engineering/Library/Android/sdk/platform-tools./adb -s emulator-5554 emu kill
Google’s Android emulator documentation:
Run apps on the Android Emulator | Android Developers
Snapshots are valid for the system image, AVD configuration, and emulator features with which they are saved. When you…
Add images of emulator.
Add command to run espresso test with no screen emulator.