How to run UiAutomator 2.0 tests from command line

In your projects base folder execute the following file:
adb install -r app/build/outputs/apk/app-debug.apk
adb install -r app/build/outputs/apk/app-debug-androidTest-unaligned.apk
# Grant permissions requested
adb shell pm grant com.example.test.uiautomatortest android.permission.READ_EXTERNAL_STORAGE
adb shell pm grant com.example.test.uiautomatortest android.permission.WRITE_EXTERNAL_STORAGE
# Run Ui tests from test class
adb shell am instrument -w -e class com.example.test.uiautomatortest.UiTests com.example.test.uiautomatortest.test/
# Pull all screenshots from device
adb pull sdcard/Screenshots/ .
# Restore device
adb uninstall com.example.test.uiautomatortest
adb uninstall com.example.test.uiautomatortest.test

Remember :
chmod +x

Dette indlæg blev udgivet i Ikke kategoriseret. Bogmærk permalinket.